Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/smbd/msdfs.c

    r596 r745  
    2323#define DBGC_CLASS DBGC_MSDFS
    2424#include "includes.h"
     25#include "system/filesys.h"
     26#include "smbd/smbd.h"
    2527#include "smbd/globals.h"
     28#include "msdfs.h"
     29#include "auth.h"
     30#include "libcli/security/security.h"
    2631
    2732/**********************************************************************
     
    5156                                bool *ppath_contains_wcard)
    5257{
     58        struct smbd_server_connection *sconn = smbd_server_conn;
    5359        char *pathname_local;
    5460        char *p,*temp;
     
    7884        sepchar = pdp->posix_path ? '/' : '\\';
    7985
    80         if (*pathname != sepchar) {
     86        if (!sconn->using_smb2 && (*pathname != sepchar)) {
    8187                DEBUG(10,("parse_dfs_path: path %s doesn't start with %c\n",
    8288                        pathname, sepchar ));
     
    212218/********************************************************
    213219 Fake up a connection struct for the VFS layer.
    214  Note this CHANGES CWD !!!! JRA.
     220 Note: this performs a vfs connect and CHANGES CWD !!!! JRA.
    215221*********************************************************/
    216222
     
    219225                                int snum,
    220226                                const char *path,
    221                                 struct auth_serversupplied_info *server_info,
     227                                const struct auth_serversupplied_info *session_info,
    222228                                char **poldcwd)
    223229{
     
    225231        char *connpath;
    226232        char *oldcwd;
     233        const char *vfs_user;
    227234
    228235        conn = TALLOC_ZERO_P(ctx, connection_struct);
     
    255262        conn->params->service = snum;
    256263
    257         if (server_info != NULL) {
    258                 conn->server_info = copy_serverinfo(conn, server_info);
    259                 if (conn->server_info == NULL) {
     264        conn->sconn = smbd_server_conn;
     265        conn->sconn->num_tcons_open++;
     266
     267        if (session_info != NULL) {
     268                conn->session_info = copy_serverinfo(conn, session_info);
     269                if (conn->session_info == NULL) {
    260270                        DEBUG(0, ("copy_serverinfo failed\n"));
    261271                        TALLOC_FREE(conn);
    262272                        return NT_STATUS_NO_MEMORY;
    263273                }
     274                vfs_user = conn->session_info->unix_name;
     275        } else {
     276                /* use current authenticated user in absence of session_info */
     277                vfs_user = get_current_username();
    264278        }
    265279
    266280        set_conn_connectpath(conn, connpath);
     281
     282        /*
     283         * New code to check if there's a share security descripter
     284         * added from NT server manager. This is done after the
     285         * smb.conf checks are done as we need a uid and token. JRA.
     286         *
     287         */
     288        if (conn->session_info) {
     289                share_access_check(conn->session_info->security_token,
     290                                   lp_servicename(snum), MAXIMUM_ALLOWED_ACCESS,
     291                                   &conn->share_access);
     292
     293                if ((conn->share_access & FILE_WRITE_DATA) == 0) {
     294                        if ((conn->share_access & FILE_READ_DATA) == 0) {
     295                                /* No access, read or write. */
     296                                DEBUG(0,("create_conn_struct: connection to %s "
     297                                         "denied due to security "
     298                                         "descriptor.\n",
     299                                         lp_servicename(snum)));
     300                                conn_free(conn);
     301                                return NT_STATUS_ACCESS_DENIED;
     302                        } else {
     303                                conn->read_only = true;
     304                        }
     305                }
     306        } else {
     307                conn->share_access = 0;
     308                conn->read_only = true;
     309        }
    267310
    268311        if (!smbd_vfs_init(conn)) {
     
    271314                conn_free(conn);
    272315                return status;
     316        }
     317
     318        /* this must be the first filesystem operation that we do */
     319        if (SMB_VFS_CONNECT(conn, lp_servicename(snum), vfs_user) < 0) {
     320                DEBUG(0,("VFS connect failed!\n"));
     321                conn_free(conn);
     322                return NT_STATUS_UNSUCCESSFUL;
    273323        }
    274324
     
    723773                        || (strequal(pdp->servicename, HOMES_NAME)
    724774                        && strequal(lp_servicename(SNUM(conn)),
    725                                 conn->server_info->sanitized_username) )) ) {
     775                                conn->session_info->sanitized_username) )) ) {
    726776
    727777                /* The given sharename doesn't match this connection. */
     
    796846
    797847NTSTATUS get_referred_path(TALLOC_CTX *ctx,
    798                         struct auth_serversupplied_info *server_info,
    799848                        const char *dfs_path,
    800849                        struct junction_map *jucn,
     
    831880        snum = lp_servicenumber(jucn->service_name);
    832881        if(snum < 0) {
    833                 fstring service_name;
    834                 fstrcpy(service_name, jucn->service_name);
    835                 if ((snum = find_service(service_name)) < 0) {
     882                char *service_name = NULL;
     883                if ((snum = find_service(ctx, jucn->service_name, &service_name)) < 0) {
    836884                        return NT_STATUS_NOT_FOUND;
     885                }
     886                if (!service_name) {
     887                        return NT_STATUS_NO_MEMORY;
    837888                }
    838889                TALLOC_FREE(jucn->service_name);
     
    918969
    919970        status = create_conn_struct(ctx, &conn, snum, lp_pathname(snum),
    920                                     server_info, &oldpath);
     971                                    NULL, &oldpath);
    921972        if (!NT_STATUS_IS_OK(status)) {
    922973                TALLOC_FREE(pdp);
     
    933984                DEBUG(3,("get_referred_path: No valid referrals for path %s\n",
    934985                        dfs_path));
    935                 vfs_ChDir(conn, oldpath);
    936                 conn_free(conn);
    937                 TALLOC_FREE(pdp);
    938                 return status;
     986                goto err_exit;
    939987        }
    940988
     
    945993                DEBUG(3,("get_referred_path: failed to parse symlink "
    946994                        "target %s\n", targetpath ));
    947                 vfs_ChDir(conn, oldpath);
    948                 conn_free(conn);
    949                 TALLOC_FREE(pdp);
    950                 return NT_STATUS_NOT_FOUND;
    951         }
    952 
     995                status = NT_STATUS_NOT_FOUND;
     996                goto err_exit;
     997        }
     998
     999        status = NT_STATUS_OK;
     1000 err_exit:
    9531001        vfs_ChDir(conn, oldpath);
     1002        SMB_VFS_DISCONNECT(conn);
    9541003        conn_free(conn);
    9551004        TALLOC_FREE(pdp);
    956         return NT_STATUS_OK;
     1005        return status;
    9571006}
    9581007
     
    12231272
    12241273        /* The following call can change cwd. */
    1225         *pstatus = get_referred_path(ctx, orig_conn->server_info,
    1226                                      pathnamep, junction,
    1227                                      &consumedcnt, &self_referral);
     1274        *pstatus = get_referred_path(ctx, pathnamep, junction,
     1275                        &consumedcnt, &self_referral);
    12281276        if (!NT_STATUS_IS_OK(*pstatus)) {
    12291277                vfs_ChDir(orig_conn,orig_conn->connectpath);
     
    13701418        if (!*pp_path_out) {
    13711419                vfs_ChDir(*conn_out, *oldpath);
     1420                SMB_VFS_DISCONNECT(*conn_out);
    13721421                conn_free(*conn_out);
    13731422                return False;
     
    14581507out:
    14591508        vfs_ChDir(conn, cwd);
     1509        SMB_VFS_DISCONNECT(conn);
    14601510        conn_free(conn);
    14611511        return ret;
     
    14891539        TALLOC_FREE(smb_fname);
    14901540        vfs_ChDir(conn, cwd);
     1541        SMB_VFS_DISCONNECT(conn);
    14911542        conn_free(conn);
    14921543        return ret;
     
    15531604out:
    15541605        vfs_ChDir(conn, cwd);
     1606        SMB_VFS_DISCONNECT(conn);
    15551607        conn_free(conn);
    15561608        return cnt;
Note: See TracChangeset for help on using the changeset viewer.