Ignore:
Timestamp:
Mar 12, 2008, 9:08:18 AM (17 years ago)
Author:
Paul Smedley
Message:

Update source to 3.0.28a

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.0/source/smbd/posix_acls.c

    r105 r124  
    13371337                                psa1->flags |= (psa2->flags & (SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT));
    13381338                                psa2->flags &= ~(SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT);
    1339                                
     1339
    13401340                        } else if (psa2->flags & SEC_ACE_FLAG_INHERIT_ONLY) {
    13411341
    13421342                                psa2->flags |= (psa1->flags & (SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT));
    13431343                                psa1->flags &= ~(SEC_ACE_FLAG_CONTAINER_INHERIT|SEC_ACE_FLAG_OBJECT_INHERIT);
    1344                                
     1344
    13451345                        }
    13461346                }
     
    14031403                } else if (sid_to_uid( &current_ace->trustee, &current_ace->unix_ug.uid)) {
    14041404                        current_ace->owner_type = UID_ACE;
    1405                         current_ace->type = SMB_ACL_USER;
     1405                        /* If it's the owning user, this is a user_obj, not
     1406                         * a user. */
     1407                        if (current_ace->unix_ug.uid == pst->st_uid) {
     1408                                current_ace->type = SMB_ACL_USER_OBJ;
     1409                        } else {
     1410                                current_ace->type = SMB_ACL_USER;
     1411                        }
    14061412                } else if (sid_to_gid( &current_ace->trustee, &current_ace->unix_ug.gid)) {
    14071413                        current_ace->owner_type = GID_ACE;
    1408                         current_ace->type = SMB_ACL_GROUP;
     1414                        /* If it's the primary group, this is a group_obj, not
     1415                         * a group. */
     1416                        if (current_ace->unix_ug.gid == pst->st_gid) {
     1417                                current_ace->type = SMB_ACL_GROUP_OBJ;
     1418                        } else {
     1419                                current_ace->type = SMB_ACL_GROUP;
     1420                        }
    14091421                } else {
    14101422                        fstring str;
     
    31003112}
    31013113
    3102 static NTSTATUS append_ugw_ace(files_struct *fsp,
    3103                         SMB_STRUCT_STAT *psbuf,
    3104                         mode_t unx_mode,
    3105                         int ugw,
    3106                         SEC_ACE *se)
    3107 {
    3108         mode_t perms;
    3109         SEC_ACCESS acc;
    3110         int nt_acl_type; /* Tru64 has "acl_type" as a macro.. */
    3111         DOM_SID trustee;
    3112 
    3113         switch (ugw) {
    3114                 case S_IRUSR:
    3115                         perms = unix_perms_to_acl_perms(unx_mode,
    3116                                                         S_IRUSR,
    3117                                                         S_IWUSR,
    3118                                                         S_IXUSR);
    3119                         uid_to_sid(&trustee, psbuf->st_uid );
    3120                         break;
    3121                 case S_IRGRP:
    3122                         perms = unix_perms_to_acl_perms(unx_mode,
    3123                                                         S_IRGRP,
    3124                                                         S_IWGRP,
    3125                                                         S_IXGRP);
    3126                         gid_to_sid(&trustee, psbuf->st_gid );
    3127                         break;
    3128                 case S_IROTH:
    3129                         perms = unix_perms_to_acl_perms(unx_mode,
    3130                                                         S_IROTH,
    3131                                                         S_IWOTH,
    3132                                                         S_IXOTH);
    3133                         sid_copy(&trustee, &global_sid_World);
    3134                         break;
    3135                 default:
    3136                         return NT_STATUS_INVALID_PARAMETER;
    3137         }
    3138         acc = map_canon_ace_perms(SNUM(fsp->conn),
    3139                                 &nt_acl_type,
    3140                                 perms,
    3141                                 fsp->is_directory);
    3142 
    3143         init_sec_ace(se,
    3144                 &trustee,
    3145                 nt_acl_type,
    3146                 acc,
    3147                 0);
    3148         return NT_STATUS_OK;
    3149 }
    3150 
    3151 /****************************************************************************
    3152  If this is an
     3114/****************************************************************************
     3115 Take care of parent ACL inheritance.
    31533116****************************************************************************/
    31543117
     
    31693132        size_t sd_size;
    31703133        unsigned int i, j;
    3171         mode_t unx_mode;
     3134        BOOL is_dacl_protected = (psd->type & SE_DESC_DACL_PROTECTED);
    31723135
    31733136        ZERO_STRUCT(sbuf);
     
    31833146                return NT_STATUS_NO_MEMORY;
    31843147        }
    3185 
    3186         /* Create a default mode for u/g/w. */
    3187         unx_mode = unix_mode(fsp->conn,
    3188                         aARCH | (fsp->is_directory ? aDIR : 0),
    3189                         fsp->fsp_name,
    3190                         parent_name);
    31913148
    31923149        status = open_directory(fsp->conn,
     
    32143171        }
    32153172
    3216         /*
     3173        /*
    32173174         * Make room for potentially all the ACLs from
    3218          * the parent, plus the user/group/other triple.
     3175         * the parent. We used to add the ugw triple here,
     3176         * as we knew we were dealing with POSIX ACLs.
     3177         * We no longer need to do so as we can guarentee
     3178         * that a default ACL from the parent directory will
     3179         * be well formed for POSIX ACLs if it came from a
     3180         * POSIX ACL source, and if we're not writing to a
     3181         * POSIX ACL sink then we don't care if it's not well
     3182         * formed. JRA.
    32193183         */
    32203184
    3221         num_aces += parent_sd->dacl->num_aces + 3;
     3185        num_aces += parent_sd->dacl->num_aces;
    32223186
    32233187        if((new_ace = TALLOC_ZERO_ARRAY(mem_ctx, SEC_ACE,
     
    32253189                return NT_STATUS_NO_MEMORY;
    32263190        }
    3227 
    3228         DEBUG(10,("append_parent_acl: parent ACL has %u entries. New "
    3229                 "ACL has %u entries\n",
    3230                 parent_sd->dacl->num_aces, num_aces ));
    32313191
    32323192        /* Start by copying in all the given ACE entries. */
     
    32403200         */
    32413201
    3242          /*
    3243           * Append u/g/w.
    3244           */
    3245 
    3246         status = append_ugw_ace(fsp, psbuf, unx_mode, S_IRUSR, &new_ace[i++]);
    3247         if (!NT_STATUS_IS_OK(status)) {
    3248                 return status;
    3249         }
    3250         status = append_ugw_ace(fsp, psbuf, unx_mode, S_IRGRP, &new_ace[i++]);
    3251         if (!NT_STATUS_IS_OK(status)) {
    3252                 return status;
    3253         }
    3254         status = append_ugw_ace(fsp, psbuf, unx_mode, S_IROTH, &new_ace[i++]);
    3255         if (!NT_STATUS_IS_OK(status)) {
    3256                 return status;
    3257         }
    3258 
    32593202        /* Finally append any inherited ACEs. */
    32603203        for (j = 0; j < parent_sd->dacl->num_aces; j++) {
    32613204                SEC_ACE *se = &parent_sd->dacl->aces[j];
    3262                 uint32 i_flags = se->flags & (SEC_ACE_FLAG_OBJECT_INHERIT|
    3263                                         SEC_ACE_FLAG_CONTAINER_INHERIT|
    3264                                         SEC_ACE_FLAG_INHERIT_ONLY);
    32653205
    32663206                if (fsp->is_directory) {
    3267                         if (i_flags == SEC_ACE_FLAG_OBJECT_INHERIT) {
    3268                                 /* Should only apply to a file - ignore. */
     3207                        if (!(se->flags & SEC_ACE_FLAG_CONTAINER_INHERIT)) {
     3208                                /* Doesn't apply to a directory - ignore. */
     3209                                DEBUG(10,("append_parent_acl: directory %s "
     3210                                        "ignoring non container "
     3211                                        "inherit flags %u on ACE with sid %s "
     3212                                        "from parent %s\n",
     3213                                        fsp->fsp_name,
     3214                                        (unsigned int)se->flags,
     3215                                        sid_string_static(&se->trustee),
     3216                                        parent_name));
    32693217                                continue;
    32703218                        }
    32713219                } else {
    3272                         if ((i_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|
    3273                                         SEC_ACE_FLAG_INHERIT_ONLY)) !=
    3274                                         SEC_ACE_FLAG_OBJECT_INHERIT) {
    3275                                 /* Should not apply to a file - ignore. */
     3220                        if (!(se->flags & SEC_ACE_FLAG_OBJECT_INHERIT)) {
     3221                                /* Doesn't apply to a file - ignore. */
     3222                                DEBUG(10,("append_parent_acl: file %s "
     3223                                        "ignoring non object "
     3224                                        "inherit flags %u on ACE with sid %s "
     3225                                        "from parent %s\n",
     3226                                        fsp->fsp_name,
     3227                                        (unsigned int)se->flags,
     3228                                        sid_string_static(&se->trustee),
     3229                                        parent_name));
    32763230                                continue;
    32773231                        }
    32783232                }
     3233
     3234                if (is_dacl_protected) {
     3235                        /* If the DACL is protected it means we must
     3236                         * not overwrite an existing ACE entry with the
     3237                         * same SID. This is order N^2. Ouch :-(. JRA. */
     3238                        unsigned int k;
     3239                        for (k = 0; k < psd->dacl->num_aces; k++) {
     3240                                if (sid_equal(&psd->dacl->aces[k].trustee,
     3241                                                &se->trustee)) {
     3242                                        break;
     3243                                }
     3244                        }
     3245                        if (k < psd->dacl->num_aces) {
     3246                                /* SID matched. Ignore. */
     3247                                DEBUG(10,("append_parent_acl: path %s "
     3248                                        "ignoring ACE with protected sid %s "
     3249                                        "from parent %s\n",
     3250                                        fsp->fsp_name,
     3251                                        sid_string_static(&se->trustee),
     3252                                        parent_name));
     3253                                continue;
     3254                        }
     3255                }
     3256
    32793257                sec_ace_copy(&new_ace[i], se);
    32803258                if (se->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) {
     
    32823260                }
    32833261                new_ace[i].flags |= SEC_ACE_FLAG_INHERITED_ACE;
     3262
     3263                if (fsp->is_directory) {
     3264                        /*
     3265                         * Strip off any inherit only. It's applied.
     3266                         */
     3267                        new_ace[i].flags &= ~(SEC_ACE_FLAG_INHERIT_ONLY);
     3268                        if (se->flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) {
     3269                                /* No further inheritance. */
     3270                                new_ace[i].flags &=
     3271                                        ~(SEC_ACE_FLAG_CONTAINER_INHERIT|
     3272                                        SEC_ACE_FLAG_OBJECT_INHERIT);
     3273                        }
     3274                } else {
     3275                        /*
     3276                         * Strip off any container or inherit
     3277                         * flags, they can't apply to objects.
     3278                         */
     3279                        new_ace[i].flags &= ~(SEC_ACE_FLAG_CONTAINER_INHERIT|
     3280                                                SEC_ACE_FLAG_INHERIT_ONLY|
     3281                                                SEC_ACE_FLAG_NO_PROPAGATE_INHERIT);
     3282                }
     3283
    32843284                i++;
     3285
     3286                DEBUG(10,("append_parent_acl: path %s "
     3287                        "inheriting ACE with sid %s "
     3288                        "from parent %s\n",
     3289                        fsp->fsp_name,
     3290                        sid_string_static(&se->trustee),
     3291                        parent_name));
     3292
    32853293        }
    32863294
Note: See TracChangeset for help on using the changeset viewer.