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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/sysacls.c

    r740 r988  
    1 /* 
     1/*
    22   Unix SMB/CIFS implementation.
    33   Samba system utilities for ACL support.
     
    55   Copyright (C) Volker Lendecke 2006
    66   Copyright (C) Michael Adam 2006,2008
    7    
     7
    88   This program is free software; you can redistribute it and/or modify
    99   it under the terms of the GNU General Public License as published by
    1010   the Free Software Foundation; either version 3 of the License, or
    1111   (at your option) any later version.
    12    
     12
    1313   This program is distributed in the hope that it will be useful,
    1414   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616   GNU General Public License for more details.
    17    
     17
    1818   You should have received a copy of the GNU General Public License
    1919   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    3131#endif
    3232
    33 #if defined(HAVE_SOLARIS_ACLS) || defined(HAVE_UNIXWARE_ACLS)
     33#if defined(HAVE_SOLARIS_UNIXWARE_ACLS)
    3434#include "modules/vfs_solarisacl.h"
    3535#endif
     
    3737#if defined(HAVE_HPUX_ACLS)
    3838#include "modules/vfs_hpuxacl.h"
    39 #endif
    40 
    41 #if defined(HAVE_IRIX_ACLS)
    42 #include "modules/vfs_irixacl.h"
    4339#endif
    4440
     
    108104{
    109105        if (entry_d->a_type == SMB_ACL_USER) {
    110                 return &entry_d->uid;
    111                 }
     106                return &entry_d->info.user.uid;
     107        }
    112108
    113109        if (entry_d->a_type == SMB_ACL_GROUP) {
    114                 return &entry_d->gid;
     110                return &entry_d->info.group.gid;
    115111        }
    116112
    117113        errno = EINVAL;
    118                 return NULL;
     114        return NULL;
    119115}
    120116
     
    132128                errno = EINVAL;
    133129                return -1;
    134                 }
    135  
     130        }
     131
    136132        if (permset_d == NULL) {
    137133                errno = EINVAL;
     
    140136
    141137        *permset_d |= perm;
    142  
     138
    143139        return 0;
    144140}
     
    149145}
    150146
    151 char *sys_acl_to_text(SMB_ACL_T acl_d, ssize_t *len_p)
     147char *sys_acl_to_text(const struct smb_acl_t *acl_d, ssize_t *len_p)
    152148{
    153149        int     i;
     
    188184                                tag = tagbuf;
    189185                                break;
    190  
     186
    191187                        case SMB_ACL_USER:
    192                                 id = uidtoname(ap->uid);
     188                                id = uidtoname(ap->info.user.uid);
     189                                /* FALL TROUGH */
    193190                        case SMB_ACL_USER_OBJ:
    194191                                tag = "user";
     
    196193
    197194                        case SMB_ACL_GROUP:
    198                                 if ((gr = getgrgid(ap->gid)) == NULL) {
     195                                if ((gr = getgrgid(ap->info.group.gid)) == NULL) {
    199196                                        slprintf(idbuf, sizeof(idbuf)-1, "%ld",
    200                                                 (long)ap->gid);
     197                                                (long)ap->info.group.gid);
    201198                                        id = idbuf;
    202199                                } else {
    203200                                        id = gr->gr_name;
    204201                                }
     202                                /* FALL TROUGH */
    205203                        case SMB_ACL_GROUP_OBJ:
    206204                                tag = "group";
     
    234232                        maxlen += nbytes + 20 * (acl_d->count - i);
    235233                        if ((text = (char *)SMB_REALLOC(text, maxlen)) == NULL) {
    236                         errno = ENOMEM;
     234                                errno = ENOMEM;
    237235                                return NULL;
     236                        }
    238237                }
    239         }
    240 
    241                 slprintf(&text[len], nbytes-1, "%s:%s:%s\n", tag, id, perms);
    242                 len += nbytes - 1;
     238
     239
     240                slprintf(&text[len], nbytes, "%s:%s:%s\n", tag, id, perms);
     241                len += (nbytes - 1);
    243242        }
    244243
     
    249248}
    250249
    251 SMB_ACL_T sys_acl_init(int count)
     250SMB_ACL_T sys_acl_init(TALLOC_CTX *mem_ctx)
    252251{
    253252        SMB_ACL_T       a;
    254253
    255         if (count < 0) {
    256                 errno = EINVAL;
    257                 return NULL;
    258         }
    259 
    260         /*
    261          * note that since the definition of the structure pointed
    262          * to by the SMB_ACL_T includes the first element of the
    263          * acl[] array, this actually allocates an ACL with room
    264          * for (count+1) entries
    265          */
    266         if ((a = (struct smb_acl_t *)SMB_MALLOC(
    267                      sizeof(struct smb_acl_t) +
    268                      count * sizeof(struct smb_acl_entry))) == NULL) {
     254        if ((a = talloc(mem_ctx, struct smb_acl_t)) == NULL) {
    269255                errno = ENOMEM;
    270256                return NULL;
    271257        }
    272  
    273         a->size = count + 1;
     258
    274259        a->count = 0;
    275260        a->next = -1;
    276261
     262        a->acl = talloc_array(a, struct smb_acl_entry, 0);
     263        if (!a->acl) {
     264                TALLOC_FREE(a);
     265                errno = ENOMEM;
     266                return NULL;
     267        }
     268
    277269        return a;
    278270}
     
    282274        SMB_ACL_T       acl_d;
    283275        SMB_ACL_ENTRY_T entry_d;
     276        struct smb_acl_entry *acl;
    284277
    285278        if (acl_p == NULL || entry_p == NULL || (acl_d = *acl_p) == NULL) {
     
    288281        }
    289282
    290         if (acl_d->count >= acl_d->size) {
    291                 errno = ENOSPC;
    292                 return -1;
    293         }
    294 
    295         entry_d         = &acl_d->acl[acl_d->count++];
     283        acl = talloc_realloc(acl_d, acl_d->acl, struct smb_acl_entry, acl_d->count+1);
     284        if (!acl) {
     285                errno = ENOMEM;
     286                return -1;
     287        }
     288        acl_d->acl = acl;
     289        entry_d         = &acl_d->acl[acl_d->count];
    296290        entry_d->a_type = SMB_ACL_TAG_INVALID;
    297         entry_d->uid    = -1;
    298         entry_d->gid    = -1;
    299291        entry_d->a_perm = 0;
    300292        *entry_p        = entry_d;
    301293
     294        acl_d->count++;
    302295        return 0;
    303296}
     
    325318{
    326319        if (entry_d->a_type == SMB_ACL_USER) {
    327                 entry_d->uid = *((uid_t *)qual_p);
     320                entry_d->info.user.uid = *((uid_t *)qual_p);
    328321                return 0;
    329                 }
     322        }
    330323        if (entry_d->a_type == SMB_ACL_GROUP) {
    331                 entry_d->gid = *((gid_t *)qual_p);
     324                entry_d->info.group.gid = *((gid_t *)qual_p);
    332325                return 0;
    333326        }
     
    345338
    346339        entry_d->a_perm = *permset_d;
    347  
     340
    348341        return 0;
    349342}
     
    352345{
    353346        SAFE_FREE(text);
    354         return 0;
    355 }
    356 
    357 int sys_acl_free_acl(SMB_ACL_T acl_d)
    358 {
    359         SAFE_FREE(acl_d);
    360         return 0;
    361 }
    362 
    363 int sys_acl_free_qualifier(void *qual, SMB_ACL_TAG_T tagtype)
    364 {
    365347        return 0;
    366348}
     
    377359 * statically-bound acl vfs module, but they are replacable.
    378360 */
    379  
     361
    380362#if defined(HAVE_POSIX_ACLS)
    381  
    382 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, 
    383                            const char *path_p, SMB_ACL_TYPE_T type)
    384 {
    385         return posixacl_sys_acl_get_file(handle, path_p, type);
    386 }
    387  
    388 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
    389 {
    390         return posixacl_sys_acl_get_fd(handle, fsp);
    391 }
    392  
     363
     364SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
     365                           const char *path_p, SMB_ACL_TYPE_T type, TALLOC_CTX *mem_ctx)
     366{
     367        return posixacl_sys_acl_get_file(handle, path_p, type, mem_ctx);
     368}
     369
     370SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, TALLOC_CTX *mem_ctx)
     371{
     372        return posixacl_sys_acl_get_fd(handle, fsp, mem_ctx);
     373}
     374
    393375int sys_acl_set_file(vfs_handle_struct *handle,
    394376                     const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
     
    396378        return posixacl_sys_acl_set_file(handle, name, type, acl_d);
    397379}
    398  
     380
    399381int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
    400382                   SMB_ACL_T acl_d)
     
    412394
    413395SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
    414                            const char *path_p, SMB_ACL_TYPE_T type)
    415 {
    416         return aixacl_sys_acl_get_file(handle, path_p, type);
    417 }
    418 
    419 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
    420 {
    421         return aixacl_sys_acl_get_fd(handle, fsp);
     396                           const char *path_p, SMB_ACL_TYPE_T type,
     397                           TALLOC_CTX *mem_ctx)
     398{
     399        return aixacl_sys_acl_get_file(handle, path_p, type, mem_ctx);
     400}
     401
     402SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
     403                           TALLOC_CTX *mem_ctx)
     404{
     405        return aixacl_sys_acl_get_fd(handle, fsp, mem_ctx);
    422406}
    423407
     
    441425
    442426#elif defined(HAVE_TRU64_ACLS)
    443  
     427
    444428SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
    445                            const char *path_p, SMB_ACL_TYPE_T type)
    446 {
    447         return tru64acl_sys_acl_get_file(handle, path_p, type);
    448 }
    449 
    450 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
    451 {
    452         return tru64acl_sys_acl_get_fd(handle, fsp);
     429                           const char *path_p, SMB_ACL_TYPE_T type,
     430                           TALLOC_CTX *mem_ctx)
     431{
     432        return tru64acl_sys_acl_get_file(handle, path_p, type,
     433                                         mem_ctx);
     434}
     435
     436SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
     437                         TALLOC_CTX *mem_ctx)
     438{
     439        return tru64acl_sys_acl_get_fd(handle, fsp, mem_ctx);
    453440}
    454441
     
    471458}
    472459
    473 #elif defined(HAVE_SOLARIS_ACLS) || defined(HAVE_UNIXWARE_ACLS)
     460#elif defined(HAVE_SOLARIS_UNIXWARE_ACLS)
    474461
    475462SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
    476                            const char *path_p, SMB_ACL_TYPE_T type)
    477 {
    478         return solarisacl_sys_acl_get_file(handle, path_p, type);
    479 }
    480 
    481 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
    482 {
    483         return solarisacl_sys_acl_get_fd(handle, fsp);
     463                           const char *path_p, SMB_ACL_TYPE_T type,
     464                           TALLOC_CTX *mem_ctx)
     465{
     466        return solarisacl_sys_acl_get_file(handle, path_p, type,
     467                                           mem_ctx);
     468}
     469
     470SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
     471                         TALLOC_CTX *mem_ctx)
     472{
     473        return solarisacl_sys_acl_get_fd(handle, fsp,
     474                                         mem_ctx);
    484475}
    485476
     
    505496
    506497SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
    507                            const char *path_p, SMB_ACL_TYPE_T type)
    508 {
    509         return hpuxacl_sys_acl_get_file(handle, path_p, type);
    510 }
    511 
    512 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
    513 {
    514         return hpuxacl_sys_acl_get_fd(handle, fsp);
     498                           const char *path_p, SMB_ACL_TYPE_T type,
     499                           TALLOC_CTX *mem_ctx)
     500{
     501        return hpuxacl_sys_acl_get_file(handle, path_p, type, mem_ctx);
     502}
     503
     504SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
     505                           TALLOC_CTX *mem_ctx)
     506{
     507        return hpuxacl_sys_acl_get_fd(handle, fsp, mem_ctx);
    515508}
    516509
     
    533526}
    534527
    535 #elif defined(HAVE_IRIX_ACLS)
     528#else /* No ACLs. */
    536529
    537530SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
    538                            const char *path_p, SMB_ACL_TYPE_T type)
    539 {
    540         return irixacl_sys_acl_get_file(handle, path_p, type);
    541 }
    542 
    543 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
    544 {
    545         return irixacl_sys_acl_get_fd(handle, fsp);
    546 }
    547 
    548 int sys_acl_set_file(vfs_handle_struct *handle,
    549                      const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d)
    550 {
    551         return irixacl_sys_acl_set_file(handle, name, type, acl_d);
    552 }
    553 
    554 int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp,
    555                    SMB_ACL_T acl_d)
    556 {
    557         return irixacl_sys_acl_set_fd(handle, fsp, acl_d);
    558 }
    559 
    560 int sys_acl_delete_def_file(vfs_handle_struct *handle,
    561                             const char *path)
    562 {
    563         return irixacl_sys_acl_delete_def_file(handle, path);
    564 }
    565 
    566 #else /* No ACLs. */
    567 
    568 SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle,
    569                            const char *path_p, SMB_ACL_TYPE_T type)
     531                           const char *path_p, SMB_ACL_TYPE_T type,
     532                           TALLOC_CTX *mem_ctx)
    570533{
    571534#ifdef ENOTSUP
     
    577540}
    578541
    579 SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp)
     542SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp,
     543                         TALLOC_CTX *mem_ctx)
    580544{
    581545#ifdef ENOTSUP
Note: See TracChangeset for help on using the changeset viewer.