Ignore:
Timestamp:
Jun 17, 2009, 2:19:52 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.3 branch to 3.3.5

Location:
branches/samba-3.3.x/source/smbd
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/smbd/file_access.c

    r222 r274  
    9393
    9494#ifdef S_ISVTX
    95         /* sticky bit means delete only by owner or root. */
     95        /* sticky bit means delete only by owner of file or by root or
     96         * by owner of directory. */
    9697        if (sbuf.st_mode & S_ISVTX) {
    9798                SMB_STRUCT_STAT sbuf_file;
     
    102103                                return True;
    103104                        }
     105                        DEBUG(10,("can_delete_file_in_directory: can't "
     106                                "stat file %s (%s)",
     107                                fname, strerror(errno) ));
    104108                        return False;
    105109                }
     
    108112                 * for bug #3348. Don't assume owning sticky bit
    109113                 * directory means write access allowed.
     114                 * Fail to delete if we're not the owner of the file,
     115                 * or the owner of the directory as we have no possible
     116                 * chance of deleting. Otherwise, go on and check the ACL.
    110117                 */
    111                 if (conn->server_info->utok.uid != sbuf_file.st_uid) {
     118                if ((conn->server_info->utok.uid != sbuf.st_uid) &&
     119                                (conn->server_info->utok.uid != sbuf_file.st_uid)) {
     120                        DEBUG(10,("can_delete_file_in_directory: not "
     121                                "owner of file %s or directory %s",
     122                                fname, dname));
    112123                        return False;
    113124                }
  • branches/samba-3.3.x/source/smbd/filename.c

    r224 r274  
    3737                                     const char *name, TALLOC_CTX *mem_ctx,
    3838                                     char **found_name);
     39static int get_real_filename_internal(connection_struct *conn,
     40                                      const char *path, const char *name,
     41                                      bool mangled,
     42                                      TALLOC_CTX *mem_ctx, char **found_name);
    3943
    4044/****************************************************************************
     
    494498                                }
    495499
    496                                 /* ENOENT is the only valid error here. */
    497                                 if ((errno != 0) && (errno != ENOENT)) {
     500                                /*
     501                                 * ENOENT/EACCESS are the only valid errors
     502                                 * here. EACCESS needs handling here for
     503                                 * "dropboxes", i.e. directories where users
     504                                 * can only put stuff with permission -wx.
     505                                 */
     506                                if ((errno != 0) && (errno != ENOENT)
     507                                    && (errno != EACCES)) {
    498508                                        /*
    499509                                         * ENOTDIR and ELOOP both map to
     
    505515                                                result =
    506516                                                NT_STATUS_OBJECT_PATH_NOT_FOUND;
    507                                         }
    508                                         else {
     517                                        } else {
    509518                                                result =
    510519                                                map_nt_error_from_unix(errno);
     
    838847                        /* Name is now unmangled. */
    839848                        name = unmangled_name;
    840                 }
    841                 return get_real_filename(conn, path, name, mem_ctx,
    842                                          found_name);
     849                } else {
     850                        /*
     851                         * If we have mangled names, do not ask the VFS'es
     852                         * GET_REAL_FILENAME. The Unix file system below does
     853                         * not know about Samba's style of mangling.
     854                         *
     855                         * Boolean flags passed down are evil, the alternative
     856                         * would be to pass a comparison function down into
     857                         * the loop in get_real_filename_internal(). For now,
     858                         * do the quick&dirty boolean flag approach.
     859                         */
     860                        return get_real_filename_internal(conn, path, name,
     861                                                          true,
     862                                                          mem_ctx, found_name);
     863                }
    843864        }
    844865
     
    847868}
    848869
    849 int get_real_filename(connection_struct *conn, const char *path,
    850                       const char *name, TALLOC_CTX *mem_ctx,
    851                       char **found_name)
     870static int get_real_filename_internal(connection_struct *conn,
     871                                      const char *path, const char *name,
     872                                      bool mangled,
     873                                      TALLOC_CTX *mem_ctx, char **found_name)
    852874{
    853875        struct smb_Dir *cur_dir;
    854876        const char *dname;
    855         bool mangled;
    856877        char *unmangled_name = NULL;
    857878        long curpos;
     
    902923        errno = ENOENT;
    903924        return -1;
     925}
     926
     927
     928
     929int get_real_filename(connection_struct *conn,
     930                      const char *path, const char *name,
     931                      TALLOC_CTX *mem_ctx, char **found_name)
     932{
     933        /*
     934         * This is the default VFS function. If we end up here, we know we
     935         * don't have mangled names around.
     936         */
     937        return get_real_filename_internal(conn, path, name, false,
     938                                          mem_ctx, found_name);
    904939}
    905940
  • branches/samba-3.3.x/source/smbd/msdfs.c

    r206 r274  
    264264        }
    265265
     266        conn->fs_capabilities = SMB_VFS_FS_CAPABILITIES(conn);
     267
    266268        /*
    267269         * Windows seems to insist on doing trans2getdfsreferral() calls on
     
    403405        SMB_STRUCT_STAT st;
    404406        int referral_len = 0;
     407#if defined(HAVE_BROKEN_READLINK)
     408        char link_target_buf[PATH_MAX];
     409#else
    405410        char link_target_buf[7];
     411#endif
    406412        size_t bufsize = 0;
    407413        char *link_target = NULL;
  • branches/samba-3.3.x/source/smbd/posix_acls.c

    r224 r274  
    11181118                return True;
    11191119
    1120         /* Assume that the current user is in the current group (force group) */
    1121 
    1122         if (uid_ace->unix_ug.uid == current_user.ut.uid && group_ace->unix_ug.gid == current_user.ut.gid)
    1123                 return True;
     1120        /*
     1121         * if it's the current user, we already have the unix token
     1122         * and don't need to do the complex user_in_group_sid() call
     1123         */
     1124        if (uid_ace->unix_ug.uid == current_user.ut.uid) {
     1125                size_t i;
     1126
     1127                if (group_ace->unix_ug.gid == current_user.ut.gid) {
     1128                        return True;
     1129                }
     1130
     1131                for (i=0; i < current_user.ut.ngroups; i++) {
     1132                        if (group_ace->unix_ug.gid == current_user.ut.groups[i]) {
     1133                                return True;
     1134                        }
     1135                }
     1136        }
    11241137
    11251138        /* u_name talloc'ed off tos. */
     
    11281141                return False;
    11291142        }
     1143
     1144        /* notice that this is not reliable for users exported by winbindd! */
    11301145        return user_in_group_sid(u_name, &group_ace->trustee);
    11311146}
  • branches/samba-3.3.x/source/smbd/posix_acls.c#

    r206 r274  
    11***************
    2 *** 4289,4298 ****
    3         if (!S_ISDIR(sbuf.st_mode)) {
     2*** 1117,1132 ****
     3        if (sid_equal(&group_ace->trustee, &global_sid_World))
     4                return True;
     5 
     6-       /* Assume that the current user is in the current group (force group) */
     7 
     8-       if (uid_ace->unix_ug.uid == current_user.ut.uid && group_ace->unix_ug.gid == current_user.ut.gid)
     9-               return True;
     10 
     11        /* u_name talloc'ed off tos. */
     12        u_name = uidtoname(uid_ace->unix_ug.uid);
     13        if (!u_name) {
    414                return False;
    515        }
    6         if (current_user.ut.uid == 0 || conn->admin_user) {
    7                 /* I'm sorry sir, I didn't know you were root... */
     16        return user_in_group_sid(u_name, &group_ace->trustee);
     17  }
     18 
     19--- 1117,1147 ----
     20        if (sid_equal(&group_ace->trustee, &global_sid_World))
    821                return True;
    9         }
    1022 
    11         /* Check primary owner write access. */
    12         if (current_user.ut.uid == sbuf.st_uid) {
    13 --- 4289,4301 ----
    14         if (!S_ISDIR(sbuf.st_mode)) {
     23+       /*
     24+        * if it's the current user, we already have the unix token
     25+        * and don't need to do the complex user_in_group_sid() call
     26+        */
     27+       if (uid_ace->unix_ug.uid == current_user.ut.uid) {
     28+               size_t i;
     29 
     30+               if (group_ace->unix_ug.gid == current_user.ut.gid) {
     31+                       return True;
     32+               }
     33+
     34+               for (i=0; i < current_user.ut.ngroups; i++) {
     35+                       if (group_ace->unix_ug.gid == current_user.ut.groups[i]) {
     36+                               return True;
     37+                       }
     38+               }
     39+       }
     40 
     41        /* u_name talloc'ed off tos. */
     42        u_name = uidtoname(uid_ace->unix_ug.uid);
     43        if (!u_name) {
    1544                return False;
    1645        }
    17 + #ifndef __OS2__
    18 +       /* Samba always runs as root on OS/2 */
    19         if (current_user.ut.uid == 0 || conn->admin_user) {
    20                 /* I'm sorry sir, I didn't know you were root... */
    21                 return True;
    22         }
    23 + #endif
     46+
     47+       /* notice that this is not reliable for users exported by winbindd! */
     48        return user_in_group_sid(u_name, &group_ace->trustee);
     49  }
    2450 
    25         /* Check primary owner write access. */
    26         if (current_user.ut.uid == sbuf.st_uid) {
  • branches/samba-3.3.x/source/smbd/server.c

    r223 r274  
    591591        /* Kick off our mDNS registration. */
    592592        if (dns_port != 0) {
    593 #ifdef WITH_DNSSD_SUPPORT
    594                 dns_register_smbd(&dns_reg, dns_port, &maxfd,
    595                                   &r_fds, &idle_timeout);
    596 #endif
    597593#ifdef WITH_AVAHI_SUPPORT
    598594                void *avahi_conn;
  • branches/samba-3.3.x/source/smbd/service.c

    r264 r274  
    291291        }
    292292
     293        if (!service_ok(res)) {
     294                res = -1;
     295        }
     296
    293297 error:
    294298
     
    741745
    742746        if (!NT_STATUS_IS_OK(status)) {
    743                 DEBUG(0, ("create_connection_server_info failed: %s\n",
     747                DEBUG(1, ("create_connection_server_info failed: %s\n",
    744748                          nt_errstr(status)));
    745749                *pstatus = status;
  • branches/samba-3.3.x/source/smbd/uid.c

    r224 r274  
    5555}
    5656
     57/****************************************************************************
     58 talloc free the conn->server_info if not used in the vuid cache.
     59****************************************************************************/
     60
     61static void free_conn_server_info_if_unused(connection_struct *conn)
     62{
     63        unsigned int i;
     64
     65        for (i = 0; i < VUID_CACHE_SIZE; i++) {
     66                struct vuid_cache_entry *ent;
     67                ent = &conn->vuid_cache.array[i];
     68                if (ent->vuid != UID_FIELD_INVALID &&
     69                                conn->server_info == ent->server_info) {
     70                        return;
     71                }
     72        }
     73        /* Not used, safe to free. */
     74        TALLOC_FREE(conn->server_info);
     75}
     76
    5777/*******************************************************************
    5878 Check if a username is OK.
     
    7898                        ent = &conn->vuid_cache.array[i];
    7999                        if (ent->vuid == vuid) {
     100                                free_conn_server_info_if_unused(conn);
    80101                                conn->server_info = ent->server_info;
    81102                                conn->read_only = ent->read_only;
     
    143164                ent->read_only = readonly_share;
    144165                ent->admin_user = admin_user;
     166                free_conn_server_info_if_unused(conn);
    145167                conn->server_info = ent->server_info;
    146168        }
     
    154176/****************************************************************************
    155177 Clear a vuid out of the connection's vuid cache
     178 This is only called on SMBulogoff.
    156179****************************************************************************/
    157180
     
    167190                if (ent->vuid == vuid) {
    168191                        ent->vuid = UID_FIELD_INVALID;
    169                         /* Ensure we're not freeing an active pointer. */
     192                        /*
     193                         * We need to keep conn->server_info around
     194                         * if it's equal to ent->server_info as a SMBulogoff
     195                         * is often followed by a SMBtdis (with an invalid
     196                         * vuid). The debug code (or regular code in
     197                         * vfs_full_audit) wants to refer to the
     198                         * conn->server_info pointer to print debug
     199                         * statements. Theoretically this is a bug,
     200                         * as once the vuid is gone the server_info
     201                         * on the conn struct isn't valid any more,
     202                         * but there's enough code that assumes
     203                         * conn->server_info is never null that
     204                         * it's easier to hold onto the old pointer
     205                         * until we get a new sessionsetupX.
     206                         * As everything is hung off the
     207                         * conn pointer as a talloc context we're not
     208                         * leaking memory here. See bug #6315. JRA.
     209                         */
    170210                        if (conn->server_info == ent->server_info) {
    171                                 conn->server_info = NULL;
     211                                ent->server_info = NULL;
     212                        } else {
     213                                TALLOC_FREE(ent->server_info);
    172214                        }
    173                         TALLOC_FREE(ent->server_info);
    174215                        ent->read_only = False;
    175216                        ent->admin_user = False;
Note: See TracChangeset for help on using the changeset viewer.