Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source4/lib/policy
Files:
1 added
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/lib/policy/gp_filesys.c

    r740 r988  
    1818 */
    1919#include "includes.h"
     20#include "system/filesys.h"
    2021#include "lib/policy/policy.h"
    2122#include "libcli/raw/smb.h"
     
    2425#include "libcli/resolve/resolve.h"
    2526#include "libcli/raw/libcliraw.h"
    26 #include <sys/stat.h>
    27 #include <fcntl.h>
    28 #include <unistd.h>
    2927#include <dirent.h>
    3028#include <errno.h>
     
    165163        lpcfg_smbcli_session_options(gp_ctx->lp_ctx, &session_options);
    166164
    167 
    168165        return smbcli_full_connection(gp_ctx,
    169166                        &gp_ctx->cli,
    170                         gp_ctx->active_dc.name,
     167                        gp_ctx->active_dc->name,
    171168                        lpcfg_smb_ports(gp_ctx->lp_ctx),
    172169                        "sysvol",
     
    255252                          "%s (remote %zu, local %zu).\n",
    256253                          remote_src, file_size, nread));
     254                close(fh_local);
    257255                talloc_free(buf);
    258256                return NT_STATUS_UNSUCCESSFUL;
     
    283281                /* Get local path by replacing backslashes with slashes */
    284282                local_rel_path = talloc_strdup(mem_ctx, list->files[i].rel_path);
    285                 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(local_rel_path, mem_ctx);
     283                if (local_rel_path == NULL) {
     284                        TALLOC_FREE(mem_ctx);
     285                        return NT_STATUS_NO_MEMORY;
     286                }
    286287                string_replace(local_rel_path, '\\', '/');
    287288
    288289                full_local_path = talloc_asprintf(mem_ctx, "%s%s", local_path,
    289290                                local_rel_path);
    290                 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(full_local_path, mem_ctx);
     291                if (full_local_path == NULL) {
     292                        TALLOC_FREE(mem_ctx);
     293                        return NT_STATUS_NO_MEMORY;
     294                }
    291295
    292296                /* If the entry is a directory, create it. */
     
    304308                full_remote_path = talloc_asprintf(mem_ctx, "%s%s", share_path,
    305309                                list->files[i].rel_path);
    306                 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(full_remote_path, mem_ctx);
     310                if (full_remote_path == NULL) {
     311                        TALLOC_FREE(mem_ctx);
     312                        return NT_STATUS_NO_MEMORY;
     313                }
    307314
    308315                /* Get the file */
     
    343350        /* Get the remote path to copy from */
    344351        share_path = gp_get_share_path(mem_ctx, gpo->file_sys_path);
    345         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(share_path, mem_ctx);
     352        if (share_path == NULL) {
     353                TALLOC_FREE(mem_ctx);
     354                return NT_STATUS_NO_MEMORY;
     355        }
    346356
    347357        /* Get the local path to copy to */
    348358        local_path = talloc_asprintf(gp_ctx, "%s/%s", gp_tmpdir(mem_ctx), gpo->name);
    349         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(local_path, mem_ctx);
     359        if (local_path == NULL) {
     360                TALLOC_FREE(mem_ctx);
     361                return NT_STATUS_NO_MEMORY;
     362        }
    350363
    351364        /* Prepare the state structure */
    352365        state = talloc_zero(mem_ctx, struct gp_list_state);
    353         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(state, mem_ctx);
     366        if (state == NULL) {
     367                TALLOC_FREE(mem_ctx);
     368                return NT_STATUS_NO_MEMORY;
     369        }
    354370
    355371        state->tree = gp_ctx->cli->tree;
     
    396412        DIR *dir;
    397413        struct dirent *dirent;
    398         char *entry_local_path;
    399         char *entry_remote_path;
     414        char *entry_local_path = NULL;
     415        char *entry_remote_path = NULL;
    400416        int local_fd, remote_fd;
    401417        int buf[1024];
    402418        int nread, total_read;
    403419        struct stat s;
     420        NTSTATUS status;
    404421
    405422        dir = opendir(local_path);
     
    412429                entry_local_path = talloc_asprintf(gp_ctx, "%s/%s", local_path,
    413430                                                   dirent->d_name);
    414                 NT_STATUS_HAVE_NO_MEMORY(entry_local_path);
     431                if (entry_local_path == NULL) {
     432                        status = NT_STATUS_NO_MEMORY;
     433                        goto done;
     434                }
    415435
    416436                entry_remote_path = talloc_asprintf(gp_ctx, "%s\\%s",
    417437                                                    remote_path, dirent->d_name);
    418                 NT_STATUS_HAVE_NO_MEMORY(entry_remote_path);
    419 
    420                 if (stat(dirent->d_name, &s) != 0) {
    421                         return NT_STATUS_UNSUCCESSFUL;
     438                if (entry_remote_path == NULL) {
     439                        status = NT_STATUS_NO_MEMORY;
     440                        goto done;
     441                }
     442
     443                if (stat(entry_local_path, &s) != 0) {
     444                        status = NT_STATUS_UNSUCCESSFUL;
     445                        goto done;
    422446                }
    423447                if (s.st_mode & S_IFDIR) {
     
    437461                                                0);
    438462                        if (remote_fd < 0) {
    439                                 talloc_free(entry_local_path);
    440                                 talloc_free(entry_remote_path);
    441463                                DEBUG(0, ("Failed to create remote file: %s\n",
    442464                                          entry_remote_path));
    443                                 return NT_STATUS_UNSUCCESSFUL;
     465                                status = NT_STATUS_UNSUCCESSFUL;
     466                                goto done;
    444467                        }
    445468                        local_fd = open(entry_local_path, O_RDONLY);
    446469                        if (local_fd < 0) {
    447                                 talloc_free(entry_local_path);
    448                                 talloc_free(entry_remote_path);
    449470                                DEBUG(0, ("Failed to open local file: %s\n",
    450471                                          entry_local_path));
    451                                 return NT_STATUS_UNSUCCESSFUL;
     472                                status = NT_STATUS_UNSUCCESSFUL;
     473                                goto done;
    452474                        }
    453475                        total_read = 0;
     
    461483                        smbcli_close(gp_ctx->cli->tree, remote_fd);
    462484                }
    463                 talloc_free(entry_local_path);
    464                 talloc_free(entry_remote_path);
    465         }
     485                TALLOC_FREE(entry_local_path);
     486                TALLOC_FREE(entry_remote_path);
     487        }
     488
     489        status = NT_STATUS_OK;
     490done:
     491        talloc_free(entry_local_path);
     492        talloc_free(entry_remote_path);
     493
    466494        closedir(dir);
    467495
    468         return NT_STATUS_OK;
     496        return status;
    469497}
    470498
     
    554582
    555583        rv = write(fd, file_content, strlen(file_content));
     584        close(fd);
    556585        if (rv != strlen(file_content)) {
    557586                DEBUG(0, ("Short write in GPT.INI\n"));
     
    559588                return NT_STATUS_UNSUCCESSFUL;
    560589        }
    561 
    562         close(fd);
    563590
    564591        /* Upload the GPT to the sysvol share on a DC */
  • vendor/current/source4/lib/policy/gp_ini.c

    r740 r988  
    1919 */
    2020#include "includes.h"
    21 #include "lib/util/util.h"
     21#include "lib/util/samba_util.h"
    2222#include "lib/policy/policy.h"
    2323
  • vendor/current/source4/lib/policy/gp_ldap.c

    r740 r988  
    6262
    6363        gpo->dn = talloc_strdup(mem_ctx, ldb_dn_get_linearized(msg->dn));
    64         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->dn, gpo);
     64        if (gpo->dn == NULL) {
     65                TALLOC_FREE(gpo);
     66                return NT_STATUS_NO_MEMORY;
     67        }
    6568
    6669        DEBUG(9, ("Parsing GPO LDAP data for %s\n", gpo->dn));
    6770
    6871        gpo->display_name = talloc_strdup(gpo, ldb_msg_find_attr_as_string(msg, "displayName", ""));
    69         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->display_name, gpo);
     72        if (gpo->display_name == NULL) {
     73                TALLOC_FREE(gpo);
     74                return NT_STATUS_NO_MEMORY;
     75        }
    7076
    7177        gpo->name = talloc_strdup(gpo, ldb_msg_find_attr_as_string(msg, "name", ""));
    72         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->name, gpo);
     78        if (gpo->name == NULL) {
     79                TALLOC_FREE(gpo);
     80                return NT_STATUS_NO_MEMORY;
     81        }
    7382
    7483        gpo->flags = ldb_msg_find_attr_as_uint(msg, "flags", 0);
     
    7685
    7786        gpo->file_sys_path = talloc_strdup(gpo, ldb_msg_find_attr_as_string(msg, "gPCFileSysPath", ""));
    78         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->file_sys_path, gpo);
     87        if (gpo->file_sys_path == NULL) {
     88                TALLOC_FREE(gpo);
     89                return NT_STATUS_NO_MEMORY;
     90        }
    7991
    8092        /* Pull the security descriptor through the NDR library */
    8193        data = ldb_msg_find_ldb_val(msg, "nTSecurityDescriptor");
    8294        gpo->security_descriptor = talloc(gpo, struct security_descriptor);
    83         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->security_descriptor, gpo);
     95        if (gpo->security_descriptor == NULL) {
     96                TALLOC_FREE(gpo);
     97                return NT_STATUS_NO_MEMORY;
     98        }
    8499
    85100        ndr_err = ndr_pull_struct_blob(data,
     
    178193        }
    179194
    180 
    181195        *gp_ctx = talloc_zero(mem_ctx, struct gp_context);
    182196        NT_STATUS_HAVE_NO_MEMORY(gp_ctx);
     
    186200        (*gp_ctx)->ev_ctx = ev_ctx;
    187201        (*gp_ctx)->ldb_ctx = ldb_ctx;
    188         (*gp_ctx)->active_dc = io->out.dcs[0];
     202        (*gp_ctx)->active_dc = talloc_reference(*gp_ctx, &io->out.dcs[0]);
    189203
    190204        /* We don't need to keep the libnet context */
     
    220234
    221235        attrs = talloc_array(mem_ctx, const char *, 7);
    222         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(attrs, mem_ctx);
     236        if (attrs == NULL) {
     237                TALLOC_FREE(mem_ctx);
     238                return NT_STATUS_NO_MEMORY;
     239        }
    223240
    224241        attrs[0] = "nTSecurityDescriptor";
     
    238255
    239256        gpo = talloc_array(gp_ctx, struct gp_object *, result->count+1);
    240         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo, mem_ctx);
     257        if (gpo == NULL) {
     258                TALLOC_FREE(mem_ctx);
     259                return NT_STATUS_NO_MEMORY;
     260        }
    241261
    242262        gpo[result->count] = NULL;
     
    275295
    276296        attrs = talloc_array(mem_ctx, const char *, 7);
    277         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(attrs, mem_ctx);
     297        if (attrs == NULL) {
     298                TALLOC_FREE(mem_ctx);
     299                return NT_STATUS_NO_MEMORY;
     300        }
    278301
    279302        attrs[0] = "nTSecurityDescriptor";
     
    343366                                                          gplink_str + start,
    344367                                                          pos - start);
    345                         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplinks[idx]->dn, gplinks);
     368                        if (gplinks[idx]->dn == NULL) {
     369                                TALLOC_FREE(gplinks);
     370                                return NT_STATUS_NO_MEMORY;
     371                        }
    346372
    347373                        for (start = pos + 1; gplink_str[pos] != ']'; pos++);
    348374
    349375                        buf = talloc_strndup(gplinks, gplink_str + start, pos - start);
    350                         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(buf, gplinks);
     376                        if (buf == NULL) {
     377                                TALLOC_FREE(gplinks);
     378                                return NT_STATUS_NO_MEMORY;
     379                        }
    351380                        gplinks[idx]->options = (uint32_t) strtoll(buf, &end, 0);
    352381                        talloc_free(buf);
     
    399428                                SMB_ASSERT(element->num_values > 0);
    400429                                gplink_str = talloc_strdup(mem_ctx, (char *) element->values[0].data);
    401                                 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
     430                                if (gplink_str == NULL) {
     431                                        TALLOC_FREE(mem_ctx);
     432                                        return NT_STATUS_NO_MEMORY;
     433                                }
    402434                                goto found;
    403435                        }
     
    405437        }
    406438        gplink_str = talloc_strdup(mem_ctx, "");
    407         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
     439        if (gplink_str == NULL) {
     440                TALLOC_FREE(mem_ctx);
     441                return NT_STATUS_NO_MEMORY;
     442        }
    408443
    409444        found:
     
    481516
    482517        gpos = talloc_array(gp_ctx, const char *, 1);
    483         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpos, mem_ctx);
     518        if (gpos == NULL) {
     519                TALLOC_FREE(mem_ctx);
     520                return NT_STATUS_NO_MEMORY;
     521        }
    484522        gpos[0] = NULL;
    485523
     
    561599                        /* Add the GPO to the list */
    562600                        gpos = talloc_realloc(gp_ctx, gpos, const char *, count+2);
    563                         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpos, mem_ctx);
     601                        if (gpos == NULL) {
     602                                TALLOC_FREE(mem_ctx);
     603                                return NT_STATUS_NO_MEMORY;
     604                        }
    564605                        gpos[count] = talloc_strdup(gp_ctx, gplinks[i]->dn);
    565                         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpos[count], mem_ctx);
     606                        if (gpos[count] == NULL) {
     607                                TALLOC_FREE(mem_ctx);
     608                                return NT_STATUS_NO_MEMORY;
     609                        }
    566610                        gpos[count+1] = NULL;
    567611                        count++;
     
    626670                }
    627671                gplink_str = talloc_asprintf(mem_ctx, "%s;%d%s", gplink_str, gplink->options, start);
    628                 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
     672                if (gplink_str == NULL) {
     673                        TALLOC_FREE(mem_ctx);
     674                        return NT_STATUS_NO_MEMORY;
     675                }
    629676
    630677        } else {
    631678                /* Prepend the new GPO link to the string. This list is backwards in priority. */
    632679                gplink_str = talloc_asprintf(mem_ctx, "[LDAP://%s;%d]%s", gplink->dn, gplink->options, gplink_str);
    633                 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
     680                if (gplink_str == NULL) {
     681                        TALLOC_FREE(mem_ctx);
     682                        return NT_STATUS_NO_MEMORY;
     683                }
    634684        }
    635685
     
    637687
    638688        msg = ldb_msg_new(mem_ctx);
    639         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     689        if (msg == NULL) {
     690                TALLOC_FREE(mem_ctx);
     691                return NT_STATUS_NO_MEMORY;
     692        }
    640693
    641694        msg->dn = dn;
    642695
    643696        rv = ldb_msg_add_string(msg, "gPLink", gplink_str);
    644         if (rv != 0) {
     697        if (rv != LDB_SUCCESS) {
    645698                DEBUG(0, ("LDB message add string failed: %s\n", ldb_strerror(rv)));
    646699                talloc_free(mem_ctx);
     
    650703
    651704        rv = ldb_modify(gp_ctx->ldb_ctx, msg);
    652         if (rv != 0) {
     705        if (rv != LDB_SUCCESS) {
    653706                DEBUG(0, ("LDB modify failed: %s\n", ldb_strerror(rv)));
    654707                talloc_free(mem_ctx);
     
    693746        /* If this GPO link already exists, alter the options, else add it */
    694747        search_string = talloc_asprintf(mem_ctx, "[LDAP://%s]", gplink_dn);
    695         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(search_string, mem_ctx);
     748        if (search_string == NULL) {
     749                TALLOC_FREE(mem_ctx);
     750                return NT_STATUS_NO_MEMORY;
     751        }
    696752
    697753        p = strcasestr(gplink_str, search_string);
     
    708764        p++;
    709765        gplink_str = talloc_asprintf(mem_ctx, "%s%s", gplink_str, p);
    710         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
     766        if (gplink_str == NULL) {
     767                TALLOC_FREE(mem_ctx);
     768                return NT_STATUS_NO_MEMORY;
     769        }
    711770
    712771
    713772        msg = ldb_msg_new(mem_ctx);
    714         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     773        if (msg == NULL) {
     774                TALLOC_FREE(mem_ctx);
     775                return NT_STATUS_NO_MEMORY;
     776        }
    715777
    716778        msg->dn = dn;
     
    718780        if (strcmp(gplink_str, "") == 0) {
    719781                rv = ldb_msg_add_empty(msg, "gPLink", LDB_FLAG_MOD_DELETE, NULL);
    720                 if (rv != 0) {
     782                if (rv != LDB_SUCCESS) {
    721783                        DEBUG(0, ("LDB message add empty element failed: %s\n", ldb_strerror(rv)));
    722784                        talloc_free(mem_ctx);
     
    725787        } else {
    726788                rv = ldb_msg_add_string(msg, "gPLink", gplink_str);
    727                 if (rv != 0) {
     789                if (rv != LDB_SUCCESS) {
    728790                        DEBUG(0, ("LDB message add string failed: %s\n", ldb_strerror(rv)));
    729791                        talloc_free(mem_ctx);
     
    733795        }
    734796        rv = ldb_modify(gp_ctx->ldb_ctx, msg);
    735         if (rv != 0) {
     797        if (rv != LDB_SUCCESS) {
    736798                DEBUG(0, ("LDB modify failed: %s\n", ldb_strerror(rv)));
    737799                talloc_free(mem_ctx);
     
    787849
    788850        inheritance_string = talloc_asprintf(msg, "%d", inheritance);
    789         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(inheritance_string, msg);
     851        if (inheritance_string == NULL) {
     852                TALLOC_FREE(msg);
     853                return NT_STATUS_NO_MEMORY;
     854        }
    790855
    791856        rv = ldb_msg_add_string(msg, "gPOptions", inheritance_string);
    792         if (rv != 0) {
     857        if (rv != LDB_SUCCESS) {
    793858                DEBUG(0, ("LDB message add string failed: %s\n", ldb_strerror(rv)));
    794859                talloc_free(msg);
     
    798863
    799864        rv = ldb_modify(gp_ctx->ldb_ctx, msg);
    800         if (rv != 0) {
     865        if (rv != LDB_SUCCESS) {
    801866                DEBUG(0, ("LDB modify failed: %s\n", ldb_strerror(rv)));
    802867                talloc_free(msg);
     
    821886        /* CN={GUID} */
    822887        msg = ldb_msg_new(mem_ctx);
    823         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     888        if (msg == NULL) {
     889                TALLOC_FREE(mem_ctx);
     890                return NT_STATUS_NO_MEMORY;
     891        }
    824892
    825893        msg->dn = ldb_get_default_basedn(gp_ctx->ldb_ctx);
    826894        dn_str = talloc_asprintf(mem_ctx, "CN=%s,CN=Policies,CN=System", gpo->name);
    827         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(dn_str, mem_ctx);
     895        if (dn_str == NULL) {
     896                TALLOC_FREE(mem_ctx);
     897                return NT_STATUS_NO_MEMORY;
     898        }
    828899
    829900        child_dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, dn_str);
     
    832903
    833904        flags_str = talloc_asprintf(mem_ctx, "%d", gpo->flags);
    834         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(flags_str, mem_ctx);
     905        if (flags_str == NULL) {
     906                TALLOC_FREE(mem_ctx);
     907                return NT_STATUS_NO_MEMORY;
     908        }
    835909
    836910        version_str = talloc_asprintf(mem_ctx, "%d", gpo->version);
    837         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(version_str, mem_ctx);
     911        if (version_str == NULL) {
     912                TALLOC_FREE(mem_ctx);
     913                return NT_STATUS_NO_MEMORY;
     914        }
    838915
    839916        rv = ldb_msg_add_string(msg, "objectClass", "top");
     
    871948        /* CN=User */
    872949        msg = ldb_msg_new(mem_ctx);
    873         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     950        if (msg == NULL) {
     951                TALLOC_FREE(mem_ctx);
     952                return NT_STATUS_NO_MEMORY;
     953        }
    874954
    875955        msg->dn = ldb_dn_copy(mem_ctx, gpo_dn);
     
    898978        /* CN=Machine */
    899979        msg = ldb_msg_new(mem_ctx);
    900         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     980        if (msg == NULL) {
     981                TALLOC_FREE(mem_ctx);
     982                return NT_STATUS_NO_MEMORY;
     983        }
    901984
    902985        msg->dn = ldb_dn_copy(mem_ctx, gpo_dn);
     
    9241007
    9251008        gpo->dn = talloc_strdup(gpo, ldb_dn_get_linearized(gpo_dn));
    926         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->dn, mem_ctx);
     1009        if (gpo->dn == NULL) {
     1010                TALLOC_FREE(mem_ctx);
     1011                return NT_STATUS_NO_MEMORY;
     1012        }
    9271013
    9281014        talloc_free(mem_ctx);
     
    9591045        /* Create a LDB message */
    9601046        msg = ldb_msg_new(mem_ctx);
    961         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     1047        if (msg == NULL) {
     1048                TALLOC_FREE(mem_ctx);
     1049                return NT_STATUS_NO_MEMORY;
     1050        }
    9621051
    9631052        msg->dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, dn_str);
    9641053
    9651054        rv = ldb_msg_add_value(msg, "nTSecurityDescriptor", &data, NULL);
    966         if (rv != 0) {
     1055        if (rv != LDB_SUCCESS) {
    9671056                DEBUG(0, ("LDB message add element failed for adding nTSecurityDescriptor: %s\n", ldb_strerror(rv)));
    9681057                talloc_free(mem_ctx);
     
    9721061
    9731062        rv = ldb_modify(gp_ctx->ldb_ctx, msg);
    974         if (rv != 0) {
     1063        if (rv != LDB_SUCCESS) {
    9751064                DEBUG(0, ("LDB modify failed: %s\n", ldb_strerror(rv)));
    9761065                talloc_free(mem_ctx);
     
    9931082
    9941083        msg = ldb_msg_new(mem_ctx);
    995         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     1084        if (msg == NULL) {
     1085                TALLOC_FREE(mem_ctx);
     1086                return NT_STATUS_NO_MEMORY;
     1087        }
    9961088
    9971089        msg->dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, gpo->dn);
    9981090
    9991091        version_str = talloc_asprintf(mem_ctx, "%d", gpo->version);
    1000         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     1092        if (msg == NULL) {
     1093                TALLOC_FREE(mem_ctx);
     1094                return NT_STATUS_NO_MEMORY;
     1095        }
    10011096
    10021097        flags_str = talloc_asprintf(mem_ctx, "%d", gpo->flags);
    1003         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
     1098        if (msg == NULL) {
     1099                TALLOC_FREE(mem_ctx);
     1100                return NT_STATUS_NO_MEMORY;
     1101        }
    10041102
    10051103        rv = ldb_msg_add_string(msg, "flags", flags_str);
    1006         if (rv != 0) {
     1104        if (rv != LDB_SUCCESS) {
    10071105                DEBUG(0, ("LDB message add string failed for flags: %s\n", ldb_strerror(rv)));
    10081106                talloc_free(mem_ctx);
     
    10121110
    10131111        rv = ldb_msg_add_string(msg, "version", version_str);
    1014         if (rv != 0) {
     1112        if (rv != LDB_SUCCESS) {
    10151113                DEBUG(0, ("LDB message add string failed for version: %s\n", ldb_strerror(rv)));
    10161114                talloc_free(mem_ctx);
     
    10201118
    10211119        rv = ldb_msg_add_string(msg, "displayName", gpo->display_name);
    1022         if (rv != 0) {
     1120        if (rv != LDB_SUCCESS) {
    10231121                DEBUG(0, ("LDB message add string failed for displayName: %s\n", ldb_strerror(rv)));
    10241122                talloc_free(mem_ctx);
     
    10281126
    10291127        rv = ldb_modify(gp_ctx->ldb_ctx, msg);
    1030         if (rv != 0) {
     1128        if (rv != LDB_SUCCESS) {
    10311129                DEBUG(0, ("LDB modify failed: %s\n", ldb_strerror(rv)));
    10321130                talloc_free(mem_ctx);
  • vendor/current/source4/lib/policy/gp_manage.c

    r740 r988  
    2525#include "lib/policy/policy.h"
    2626
    27 static uint32_t gp_ads_to_dir_access_mask(uint32_t access_mask)
     27uint32_t gp_ads_to_dir_access_mask(uint32_t access_mask)
    2828{
    2929        uint32_t fs_mask;
     
    6868        /* Copy the basic information from the directory server security descriptor */
    6969        fs_sd->owner_sid = talloc_memdup(fs_sd, ds_sd->owner_sid, sizeof(struct dom_sid));
    70         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->owner_sid, fs_sd);
     70        if (fs_sd->owner_sid == NULL) {
     71                TALLOC_FREE(fs_sd);
     72                return NT_STATUS_NO_MEMORY;
     73        }
    7174
    7275        fs_sd->group_sid = talloc_memdup(fs_sd, ds_sd->group_sid, sizeof(struct dom_sid));
    73         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->group_sid, fs_sd);
     76        if (fs_sd->group_sid == NULL) {
     77                TALLOC_FREE(fs_sd);
     78                return NT_STATUS_NO_MEMORY;
     79        }
    7480
    7581        fs_sd->type = ds_sd->type;
     
    7884        /* Copy the sacl */
    7985        fs_sd->sacl = security_acl_dup(fs_sd, ds_sd->sacl);
    80         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->sacl, fs_sd);
     86        if (fs_sd->sacl == NULL) {
     87                TALLOC_FREE(fs_sd);
     88                return NT_STATUS_NO_MEMORY;
     89        }
    8190
    8291        /* Copy the dacl */
    8392        fs_sd->dacl = talloc_zero(fs_sd, struct security_acl);
    84         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->dacl, fs_sd);
     93        if (fs_sd->dacl == NULL) {
     94                TALLOC_FREE(fs_sd);
     95                return NT_STATUS_NO_MEMORY;
     96        }
    8597
    8698        for (i = 0; i < ds_sd->dacl->num_aces; i++) {
     
    97109                /* Copy the ace from the directory server security descriptor */
    98110                ace = talloc_memdup(fs_sd, &ds_sd->dacl->aces[i], sizeof(struct security_ace));
    99                 NT_STATUS_HAVE_NO_MEMORY_AND_FREE(ace, fs_sd);
     111                if (ace == NULL) {
     112                        TALLOC_FREE(fs_sd);
     113                        return NT_STATUS_NO_MEMORY;
     114                }
    100115
    101116                /* Set specific inheritance flags for within the GPO */
     
    140155        /* Create the gpo struct to return later */
    141156        gpo = talloc(gp_ctx, struct gp_object);
    142         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo, mem_ctx);
     157        if (gpo == NULL) {
     158                TALLOC_FREE(mem_ctx);
     159                return NT_STATUS_NO_MEMORY;
     160        }
    143161
    144162        /* Generate a GUID */
    145163        guid_struct = GUID_random();
    146164        guid_str = GUID_string2(mem_ctx, &guid_struct);
    147         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(guid_str, mem_ctx);
     165        if (guid_str == NULL) {
     166                TALLOC_FREE(mem_ctx);
     167                return NT_STATUS_NO_MEMORY;
     168        }
    148169        name = strupper_talloc(mem_ctx, guid_str);
    149         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(name, mem_ctx);
     170        if (name == NULL) {
     171                TALLOC_FREE(mem_ctx);
     172                return NT_STATUS_NO_MEMORY;
     173        }
    150174
    151175        /* Prepare the GPO struct */
     
    155179        gpo->version = 0;
    156180        gpo->display_name = talloc_strdup(gpo, display_name);
    157         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->display_name, mem_ctx);
     181        if (gpo->display_name == NULL) {
     182                TALLOC_FREE(mem_ctx);
     183                return NT_STATUS_NO_MEMORY;
     184        }
    158185
    159186        gpo->file_sys_path = talloc_asprintf(gpo, "\\\\%s\\sysvol\\%s\\Policies\\%s", lpcfg_dnsdomain(gp_ctx->lp_ctx), lpcfg_dnsdomain(gp_ctx->lp_ctx), name);
    160         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->file_sys_path, mem_ctx);
     187        if (gpo->file_sys_path == NULL) {
     188                TALLOC_FREE(mem_ctx);
     189                return NT_STATUS_NO_MEMORY;
     190        }
    161191
    162192        /* Create the GPT */
     
    267297        /* FIXME: The local file system may be case sensitive */
    268298        filename = talloc_asprintf(mem_ctx, "%s/%s", local_path, "GPT.INI");
    269         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(filename, mem_ctx);
     299        if (filename == NULL) {
     300                TALLOC_FREE(mem_ctx);
     301                return NT_STATUS_NO_MEMORY;
     302        }
    270303        status = gp_parse_ini(mem_ctx, gp_ctx, local_path, &ini);
    271304        if (!NT_STATUS_IS_OK(status)) {
  • vendor/current/source4/lib/policy/policy.h

    r740 r988  
    2121#ifndef __POLICY_H__
    2222#define __POLICY_H__
    23 #include "libcli/libcli.h"
    2423
    2524#define GPLINK_OPT_DISABLE              (1 << 0)
    2625#define GPLINK_OPT_ENFORCE              (1 << 1)
    27 
    2826
    2927#define GPO_FLAG_USER_DISABLE           (1 << 0)
     
    3129
    3230struct security_token;
     31struct nbt_dc_name;
    3332
    3433enum gpo_inheritance {
     
    4342        struct tevent_context *ev_ctx;
    4443        struct smbcli_state *cli;
    45         struct nbt_dc_name active_dc;
     44        struct nbt_dc_name *active_dc;
    4645};
    4746
     
    124123NTSTATUS gp_create_gpt_security_descriptor (TALLOC_CTX *mem_ctx, struct security_descriptor *ds_sd, struct security_descriptor **ret);
    125124NTSTATUS gp_set_acl (struct gp_context *gp_ctx, const char *dn_str, const struct security_descriptor *sd);
     125uint32_t gp_ads_to_dir_access_mask(uint32_t access_mask);
    126126
    127127#endif
  • vendor/current/source4/lib/policy/pypolicy.c

    r740 r988  
    2222#include "policy.h"
    2323#include "libcli/util/pyerrors.h"
     24
     25void initpolicy(void);
    2426
    2527static PyObject *py_get_gpo_flags(PyObject *self, PyObject *args)
     
    107109}
    108110
     111static PyObject *py_ads_to_dir_access_mask(PyObject *self, PyObject *args)
     112{
     113        uint32_t access_mask, dir_mask;
     114
     115        if (! PyArg_ParseTuple(args, "I", &access_mask))
     116                return NULL;
     117
     118        dir_mask = gp_ads_to_dir_access_mask(access_mask);
     119
     120        return Py_BuildValue("I", dir_mask);
     121}
     122
     123
    109124static PyMethodDef py_policy_methods[] = {
    110125        { "get_gpo_flags", (PyCFunction)py_get_gpo_flags, METH_VARARGS,
    111126                "get_gpo_flags(flags) -> list" },
    112     { "get_gplink_options", (PyCFunction)py_get_gplink_options, METH_VARARGS,
    113         "get_gplink_options(options) -> list" },
     127        { "get_gplink_options", (PyCFunction)py_get_gplink_options, METH_VARARGS,
     128                "get_gplink_options(options) -> list" },
     129        { "ads_to_dir_access_mask", (PyCFunction)py_ads_to_dir_access_mask, METH_VARARGS,
     130                "ads_to_dir_access_mask(access_mask) -> dir_mask" },
    114131        { NULL }
    115132};
  • vendor/current/source4/lib/policy/wscript_build

    r740 r988  
    11#!/usr/bin/env python
    22
    3 bld.SAMBA_LIBRARY('policy',
     3bld.SAMBA_LIBRARY('samba-policy',
    44        source='gp_ldap.c gp_filesys.c gp_manage.c gp_ini.c',
    5         pc_files='policy.pc',
     5        pc_files='samba-policy.pc',
    66        public_deps='ldb samba-net',
    77        vnum='0.0.1',
    8         pyembed=True
     8        pyembed=True,
     9        public_headers='policy.h'
    910        )
    1011
    1112bld.SAMBA_PYTHON('py_policy',
    1213        source='pypolicy.c',
    13         public_deps='policy pytalloc-util',
     14        public_deps='samba-policy pytalloc-util',
    1415        realname='samba/policy.so'
    1516        )
Note: See TracChangeset for help on using the changeset viewer.