Ignore:
Timestamp:
Jul 2, 2011, 4:01:14 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update vendor to version 3.5.9

Location:
vendor/current/source3/smbd
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/dosmode.c

    r594 r597  
    794794        }
    795795
     796        /*
     797         * From the chmod 2 man page:
     798         *
     799         * "If the calling process is not privileged, and the group of the file
     800         * does not match the effective group ID of the process or one of its
     801         * supplementary group IDs, the S_ISGID bit will be turned off, but
     802         * this will not cause an error to be returned."
     803         *
     804         * Simply refuse to do the chmod in this case.
     805         */
     806
     807        if (S_ISDIR(smb_fname->st.st_ex_mode) && (unixmode & S_ISGID) &&
     808                        geteuid() != sec_initial_uid() &&
     809                        !current_user_in_group(smb_fname->st.st_ex_gid)) {
     810                DEBUG(3,("file_set_dosmode: setgid bit cannot be "
     811                        "set for directory %s\n",
     812                        smb_fname_str_dbg(smb_fname)));
     813                errno = EPERM;
     814                return -1;
     815        }
     816
     817
    796818        ret = SMB_VFS_CHMOD(conn, smb_fname->base_name, unixmode);
    797819        if (ret == 0) {
  • vendor/current/source3/smbd/fake_file.c

    r414 r597  
    127127
    128128        /* access check */
    129         if (conn->server_info->utok.uid != 0) {
     129        if (conn->server_info->utok.uid != 0 && !conn->admin_user) {
    130130                DEBUG(3, ("open_fake_file_shared: access_denied to "
    131131                          "service[%s] file[%s] user[%s]\n",
  • vendor/current/source3/smbd/filename.c

    r478 r597  
    352352                        goto done;
    353353                }
     354
     355                /* Stat failed - ensure we don't use it. */
     356                SET_STAT_INVALID(smb_fname->st);
    354357
    355358                /*
  • vendor/current/source3/smbd/nttrans.c

    r594 r597  
    23112311
    23122312        /* access check */
    2313         if (conn->server_info->utok.uid != 0) {
     2313        if (conn->server_info->utok.uid != 0 && !conn->admin_user) {
    23142314                DEBUG(1,("get_user_quota: access_denied service [%s] user "
    23152315                         "[%s]\n", lp_servicename(SNUM(conn)),
     
    25812581
    25822582        /* access check */
    2583         if (conn->server_info->utok.uid != 0) {
     2583        if (conn->server_info->utok.uid != 0 && !conn->admin_user) {
    25842584                DEBUG(1,("set_user_quota: access_denied service [%s] user "
    25852585                         "[%s]\n", lp_servicename(SNUM(conn)),
  • vendor/current/source3/smbd/open.c

    r594 r597  
    233233                         (unsigned int)smb_fname_parent->st.st_ex_uid,
    234234                         strerror(errno) ));
    235         }
    236 
    237         DEBUG(10,("change_file_owner_to_parent: changed new file %s to "
     235        } else {
     236                DEBUG(10,("change_file_owner_to_parent: changed new file %s to "
    238237                  "parent directory uid %u.\n", fsp_str_dbg(fsp),
    239238                  (unsigned int)smb_fname_parent->st.st_ex_uid));
     239
     240                /* Ensure the uid entry is updated. */
     241                fsp->fsp_name->st.st_ex_uid = smb_fname_parent->st.st_ex_uid;
     242        }
    240243
    241244        TALLOC_FREE(smb_fname_parent);
     
    312315        /* Ensure we're pointing at the same place. */
    313316        if (smb_fname_cwd->st.st_ex_dev != psbuf->st_ex_dev ||
    314             smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino ||
    315             smb_fname_cwd->st.st_ex_mode != psbuf->st_ex_mode ) {
     317            smb_fname_cwd->st.st_ex_ino != psbuf->st_ex_ino) {
    316318                DEBUG(0,("change_dir_owner_to_parent: "
    317                          "device/inode/mode on directory %s changed. "
     319                         "device/inode on directory %s changed. "
    318320                         "Refusing to chown !\n", fname ));
    319321                status = NT_STATUS_ACCESS_DENIED;
     
    338340                  "directory %s to parent directory uid %u.\n",
    339341                  fname, (unsigned int)smb_fname_parent->st.st_ex_uid ));
     342
     343        /* Ensure the uid entry is updated. */
     344        psbuf->st_ex_uid = smb_fname_parent->st.st_ex_uid;
    340345
    341346 chdir:
     
    365370        int local_flags = flags;
    366371        bool file_existed = VALID_STAT(fsp->fsp_name->st);
     372        bool file_created = false;
    367373
    368374        fsp->fh->fd = -1;
     
    464470
    465471                if ((local_flags & O_CREAT) && !file_existed) {
    466 
    467                         /* Inherit the ACL if required */
    468                         if (lp_inherit_perms(SNUM(conn))) {
    469                                 inherit_access_posix_acl(conn, parent_dir,
    470                                                          smb_fname->base_name,
    471                                                          unx_mode);
    472                         }
    473 
    474                         /* Change the owner if required. */
    475                         if (lp_inherit_owner(SNUM(conn))) {
    476                                 change_file_owner_to_parent(conn, parent_dir,
    477                                                             fsp);
    478                         }
    479 
    480                         notify_fname(conn, NOTIFY_ACTION_ADDED,
    481                                      FILE_NOTIFY_CHANGE_FILE_NAME,
    482                                      smb_fname->base_name);
     472                        file_created = true;
    483473                }
    484474
     
    589579                        fd_close(fsp);
    590580                        return status;
     581                }
     582
     583                if (file_created) {
     584                        /* Do all inheritance work after we've
     585                           done a successful stat call and filled
     586                           in the stat struct in fsp->fsp_name. */
     587
     588                        /* Inherit the ACL if required */
     589                        if (lp_inherit_perms(SNUM(conn))) {
     590                                inherit_access_posix_acl(conn, parent_dir,
     591                                                         smb_fname->base_name,
     592                                                         unx_mode);
     593                        }
     594
     595                        /* Change the owner if required. */
     596                        if (lp_inherit_owner(SNUM(conn))) {
     597                                change_file_owner_to_parent(conn, parent_dir,
     598                                                            fsp);
     599                        }
     600
     601                        notify_fname(conn, NOTIFY_ACTION_ADDED,
     602                                     FILE_NOTIFY_CHANGE_FILE_NAME,
     603                                     smb_fname->base_name);
    591604                }
    592605        }
     
    23072320        NTSTATUS status;
    23082321        bool posix_open = false;
     2322        bool need_re_stat = false;
    23092323
    23102324        if(!CAN_WRITE(conn)) {
     
    23612375                inherit_access_posix_acl(conn, parent_dir,
    23622376                                         smb_dname->base_name, mode);
     2377                need_re_stat = true;
    23632378        }
    23642379
     
    23752390                                      (smb_dname->st.st_ex_mode |
    23762391                                          (mode & ~smb_dname->st.st_ex_mode)));
     2392                        need_re_stat = true;
    23772393                }
    23782394        }
     
    23832399                                           smb_dname->base_name,
    23842400                                           &smb_dname->st);
     2401                need_re_stat = true;
     2402        }
     2403
     2404        if (need_re_stat) {
     2405                if (SMB_VFS_LSTAT(conn, smb_dname) == -1) {
     2406                        DEBUG(2, ("Could not stat directory '%s' just created: %s\n",
     2407                          smb_fname_str_dbg(smb_dname), strerror(errno)));
     2408                        return map_nt_error_from_unix(errno);
     2409                }
    23852410        }
    23862411
     
    29452970        if (lp_acl_check_permissions(SNUM(conn))
    29462971            && (create_disposition != FILE_CREATE)
    2947             && (share_access & FILE_SHARE_DELETE)
    29482972            && (access_mask & DELETE_ACCESS)
    29492973            && (!(can_delete_file_in_directory(conn, smb_fname) ||
  • vendor/current/source3/smbd/posix_acls.c

    r594 r597  
    26452645****************************************************************************/
    26462646
    2647 static bool current_user_in_group(gid_t gid)
     2647bool current_user_in_group(gid_t gid)
    26482648{
    26492649        int i;
  • vendor/current/source3/smbd/process.c

    r594 r597  
    20842084                {
    20852085                        DEBUG( 3,( "Printcap cache time expired.\n"));
    2086                         reload_printers();
     2086                        pcap_cache_reload(&reload_printers);
    20872087                        last_printer_reload_time = t;
    20882088                }
     
    23702370
    23712371        if (!(event_add_idle(smbd_event_context(), NULL,
    2372                              timeval_set(SMBD_SELECT_TIMEOUT, 0),
     2372                             timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
    23732373                             "housekeeping", housekeeping_fn, NULL))) {
    23742374                DEBUG(0, ("Could not add housekeeping event\n"));
  • vendor/current/source3/smbd/server.c

    r427 r597  
    542542}
    543543
     544static bool parent_housekeeping_fn(const struct timeval *now, void *private_data)
     545{
     546        DEBUG(5, ("houskeeping\n"));
     547        /* check if we need to reload services */
     548        check_reload(time(NULL));
     549        return true;
     550}
     551
    544552/****************************************************************************
    545553 Open the socket communication.
     
    601609                                }
    602610
     611                                /* Keep the first port for mDNS service
     612                                 * registration.
     613                                 */
     614                                if (dns_port == 0) {
     615                                        dns_port = port;
     616                                }
     617
    603618                                if (!smbd_open_one_socket(parent, ifss, port)) {
    604619                                        return false;
     
    668683        claim_connection(NULL,"",
    669684                         FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_DBWRAP);
     685
     686        if (!(event_add_idle(smbd_event_context(), NULL,
     687                             timeval_set(SMBD_HOUSEKEEPING_INTERVAL, 0),
     688                             "parent_housekeeping", parent_housekeeping_fn,
     689                             parent))) {
     690                DEBUG(0, ("Could not add housekeeping event\n"));
     691                exit(1);
     692        }
    670693
    671694        /* Listen to messages */
     
    735758}
    736759
    737 /****************************************************************************
    738  Reload printers
    739 **************************************************************************/
     760/***************************************************************************
     761 purge stale printers and reload from pre-populated pcap cache
     762***************************************************************************/
    740763void reload_printers(void)
    741764{
     
    745768        const char *pname;
    746769
    747         pcap_cache_reload();
    748 
    749         /* remove stale printers */
     770        DEBUG(10, ("reloading printer services from pcap cache\n"));
    750771        for (snum = 0; snum < n_services; snum++) {
    751772                /* avoid removing PRINTERS_NAME or non-autoloaded printers */
     
    794815        ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
    795816
    796         reload_printers();
     817        pcap_cache_reload(&reload_printers);
    797818
    798819        /* perhaps the config filename is now set */
  • vendor/current/source3/smbd/sesssetup.c

    r587 r597  
    11021102
    11031103        asn1_load(data, *pblob);
    1104         asn1_start_tag(data, pblob->data[0]);
    1105         if (data->has_error || data->nesting == NULL) {
     1104        if (asn1_start_tag(data, pblob->data[0])) {
     1105                /* asn1_start_tag checks if the given
     1106                   length of the blob is enough to complete
     1107                   the tag. If it returns true we know
     1108                   there is nothing to do - the blob is
     1109                   complete. */
    11061110                asn1_free(data);
    1107                 /* Let caller catch. */
    11081111                return NT_STATUS_OK;
    11091112        }
     1113
     1114        if (data->nesting == NULL) {
     1115                /* Incorrect tag, allocation failed,
     1116                   or reading the tag length failed.
     1117                   Let the caller catch. */
     1118                asn1_free(data);
     1119                return NT_STATUS_OK;
     1120        }
     1121
     1122        /* Here we know asn1_start_tag() has set data->has_error to true.
     1123           asn1_tag_remaining() will have failed due to the given blob
     1124           being too short. We need to work out how short. */
    11101125
    11111126        /* Integer wrap paranoia.... */
     
    11371152        if (needed_len <= pblob->length) {
    11381153                /* Nothing to do - blob is complete. */
     1154                /* THIS SHOULD NOT HAPPEN - asn1_start_tag()
     1155                   above should have caught this !!! */
     1156                DEBUG(0,("check_spnego_blob_complete: logic "
     1157                        "error (needed_len = %u, "
     1158                        "pblob->length = %u).\n",
     1159                        (unsigned int)needed_len,
     1160                        (unsigned int)pblob->length ));
    11391161                return NT_STATUS_OK;
    11401162        }
  • vendor/current/source3/smbd/trans2.c

    r587 r597  
    31573157
    31583158                        /* access check */
    3159                         if (conn->server_info->utok.uid != sec_initial_uid()) {
     3159                        if (conn->server_info->utok.uid != sec_initial_uid() &&
     3160                                        !conn->admin_user) {
    31603161                                DEBUG(0,("set_user_quota: access_denied "
    31613162                                         "service [%s] user [%s]\n",
     
    36443645
    36453646                                /* access check */
    3646                                 if ((conn->server_info->utok.uid != sec_initial_uid())
     3647                                if (((conn->server_info->utok.uid != sec_initial_uid()) && !conn->admin_user)
    36473648                                    ||!CAN_WRITE(conn)) {
    36483649                                        DEBUG(0,("set_user_quota: access_denied service [%s] user [%s]\n",
     
    70457046        wire_open_mode &= ~SMB_ACCMODE;
    70467047
    7047         if((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) == (SMB_O_CREAT | SMB_O_EXCL)) {
    7048                 create_disp = FILE_CREATE;
    7049         } else if((wire_open_mode & (SMB_O_CREAT | SMB_O_TRUNC)) == (SMB_O_CREAT | SMB_O_TRUNC)) {
    7050                 create_disp = FILE_OVERWRITE_IF;
    7051         } else if((wire_open_mode & SMB_O_CREAT) == SMB_O_CREAT) {
    7052                 create_disp = FILE_OPEN_IF;
    7053         } else if ((wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL | SMB_O_TRUNC)) == 0) {
    7054                 create_disp = FILE_OPEN;
    7055         } else {
    7056                 DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n",
    7057                         (unsigned int)wire_open_mode ));
    7058                 return NT_STATUS_INVALID_PARAMETER;
     7048        /* First take care of O_CREAT|O_EXCL interactions. */
     7049        switch (wire_open_mode & (SMB_O_CREAT | SMB_O_EXCL)) {
     7050                case (SMB_O_CREAT | SMB_O_EXCL):
     7051                        /* File exists fail. File not exist create. */
     7052                        create_disp = FILE_CREATE;
     7053                        break;
     7054                case SMB_O_CREAT:
     7055                        /* File exists open. File not exist create. */
     7056                        create_disp = FILE_OPEN_IF;
     7057                        break;
     7058                case 0:
     7059                        /* File exists open. File not exist fail. */
     7060                        create_disp = FILE_OPEN;
     7061                        break;
     7062                case SMB_O_EXCL:
     7063                        /* O_EXCL on its own without O_CREAT is undefined. */
     7064                default:
     7065                        DEBUG(5,("smb_posix_open: invalid create mode 0x%x\n",
     7066                                (unsigned int)wire_open_mode ));
     7067                        return NT_STATUS_INVALID_PARAMETER;
     7068        }
     7069
     7070        /* Next factor in the effects of O_TRUNC. */
     7071        wire_open_mode &= ~(SMB_O_CREAT | SMB_O_EXCL);
     7072
     7073        if (wire_open_mode & SMB_O_TRUNC) {
     7074                switch (create_disp) {
     7075                        case FILE_CREATE:
     7076                                /* (SMB_O_CREAT | SMB_O_EXCL | O_TRUNC) */
     7077                                /* Leave create_disp alone as
     7078                                   (O_CREAT|O_EXCL|O_TRUNC) == (O_CREAT|O_EXCL)
     7079                                */
     7080                                /* File exists fail. File not exist create. */
     7081                                break;
     7082                        case FILE_OPEN_IF:
     7083                                /* SMB_O_CREAT | SMB_O_TRUNC */
     7084                                /* File exists overwrite. File not exist create. */
     7085                                create_disp = FILE_OVERWRITE_IF;
     7086                                break;
     7087                        case FILE_OPEN:
     7088                                /* SMB_O_TRUNC */
     7089                                /* File exists overwrite. File not exist fail. */
     7090                                create_disp = FILE_OVERWRITE;
     7091                                break;
     7092                        default:
     7093                                /* Cannot get here. */
     7094                                smb_panic("smb_posix_open: logic error");
     7095                                return NT_STATUS_INVALID_PARAMETER;
     7096                }
    70597097        }
    70607098
Note: See TracChangeset for help on using the changeset viewer.