Ignore:
Timestamp:
Mar 11, 2009, 9:14:55 AM (16 years ago)
Author:
Paul Smedley
Message:

Add 'missing' 3.0.34 diffs

File:
1 edited

Legend:

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

    r106 r165  
    143143}
    144144
     145/*******************************************************************
     146 Check if a username is OK in share level security.
     147********************************************************************/
     148
     149static bool check_user_ok_sharelevel_security(connection_struct *conn,
     150                                        const char *unix_name,
     151                                        int snum)
     152{
     153        NT_USER_TOKEN *token = conn->nt_user_token;
     154
     155        if (!user_ok_token(unix_name, token, snum)) {
     156                return false;
     157        }
     158
     159        conn->read_only = is_share_read_only_for_token(unix_name,
     160                                                      token,
     161                                                      snum);
     162
     163        if (!conn->read_only &&
     164            !share_access_check(token, lp_servicename(snum),
     165                                FILE_WRITE_DATA)) {
     166                /* smb.conf allows r/w, but the security descriptor denies
     167                 * write. Fall back to looking at readonly. */
     168                conn->read_only = true;
     169                DEBUG(5,("falling back to read-only access-evaluation due to "
     170                         "security descriptor\n"));
     171        }
     172
     173        if (!share_access_check(token, lp_servicename(snum),
     174                                conn->read_only ?
     175                                FILE_READ_DATA : FILE_WRITE_DATA)) {
     176                return false;
     177        }
     178
     179        conn->admin_user = token_contains_name_in_list(
     180                                unix_name, NULL, token,
     181                                lp_admin_users(SNUM(conn)));
     182
     183        return true;
     184}
     185
     186
    145187/****************************************************************************
    146188 Become the user of a connection number without changing the security context
     
    150192BOOL change_to_user(connection_struct *conn, uint16 vuid)
    151193{
     194        enum security_types sec = (enum security_types)lp_security();
    152195        user_struct *vuser = get_valid_user_struct(vuid);
    153 
    154196        int snum;
    155197        gid_t gid;
     
    173215         */
    174216
    175         if((lp_security() == SEC_SHARE) && (current_user.conn == conn) &&
     217        if((sec == SEC_SHARE) && (current_user.conn == conn) &&
    176218           (current_user.ut.uid == conn->uid)) {
    177219                DEBUG(4,("change_to_user: Skipping user change - already "
     
    194236                         lp_servicename(snum)));
    195237                return False;
     238        } else if ((sec == SEC_SHARE) && !check_user_ok_sharelevel_security(conn,
     239                        conn->user, snum)) {
     240                DEBUG(2,("change_to_user: unix user %s "
     241                         "not permitted access to share %s.\n",
     242                         conn->user,
     243                         lp_servicename(snum)));
     244                return false;
    196245        }
    197246
     
    273322        DEBUG(5,("change_to_user uid=(%d,%d) gid=(%d,%d)\n",
    274323                 (int)getuid(),(int)geteuid(),(int)getgid(),(int)getegid()));
    275 
     324 
    276325        return(True);
    277326}
Note: See TracChangeset for help on using the changeset viewer.