Ignore:
Timestamp:
Nov 29, 2012, 1:59:04 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/smbd/service.c

    r745 r751  
    702702                }
    703703
     704                /* We don't want to replace the original sanitized_username
     705                   as it is the original user given in the connect attempt.
     706                   This is used in '%U' substitutions. */
     707                TALLOC_FREE(forced_serverinfo->sanitized_username);
     708                forced_serverinfo->sanitized_username =
     709                        talloc_move(forced_serverinfo,
     710                                &conn->session_info->sanitized_username);
     711
    704712                TALLOC_FREE(conn->session_info);
    705713                conn->session_info = forced_serverinfo;
     
    738746
    739747/****************************************************************************
     748  Setup the share access mask for a connection.
     749****************************************************************************/
     750
     751static void create_share_access_mask(connection_struct *conn, int snum)
     752{
     753        const struct security_token *token = conn->session_info->security_token;
     754
     755        share_access_check(token,
     756                        lp_servicename(snum),
     757                        MAXIMUM_ALLOWED_ACCESS,
     758                        &conn->share_access);
     759
     760        if (security_token_has_privilege(token, SEC_PRIV_SECURITY)) {
     761                conn->share_access |= SEC_FLAG_SYSTEM_SECURITY;
     762        }
     763        if (security_token_has_privilege(token, SEC_PRIV_RESTORE)) {
     764                conn->share_access |= (SEC_RIGHTS_PRIV_RESTORE);
     765        }
     766        if (security_token_has_privilege(token, SEC_PRIV_BACKUP)) {
     767                conn->share_access |= (SEC_RIGHTS_PRIV_BACKUP);
     768        }
     769        if (security_token_has_privilege(token, SEC_PRIV_TAKE_OWNERSHIP)) {
     770                conn->share_access |= (SEC_STD_WRITE_OWNER);
     771        }
     772}
     773
     774/****************************************************************************
    740775  Make a connection, given the snum to connect to, and the vuser of the
    741776  connecting user if appropriate.
    742777****************************************************************************/
    743778
    744 connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
     779static connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
     780                                        connection_struct *conn,
    745781                                        int snum, user_struct *vuser,
    746782                                        DATA_BLOB password,
     
    748784                                        NTSTATUS *pstatus)
    749785{
    750         connection_struct *conn = NULL;
    751786        struct smb_filename *smb_fname_cpath = NULL;
    752787        fstring dev;
     
    765800        }
    766801
    767         conn = conn_new(sconn);
    768         if (!conn) {
    769                 DEBUG(0,("Couldn't find free connection.\n"));
    770                 *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
    771                 goto err_root_exit;
    772         }
    773 
    774802        conn->params->service = snum;
    775803
     
    821849        status = set_conn_force_user_group(conn, snum);
    822850        if (!NT_STATUS_IS_OK(status)) {
    823                 conn_free(conn);
    824851                *pstatus = status;
    825852                return NULL;
     
    859886         */
    860887
    861         share_access_check(conn->session_info->security_token,
    862                            lp_servicename(snum), MAXIMUM_ALLOWED_ACCESS,
    863                            &conn->share_access);
     888        create_share_access_mask(conn, snum);
    864889
    865890        if ((conn->share_access & FILE_WRITE_DATA) == 0) {
     
    11181143                yield_connection(conn, lp_servicename(snum));
    11191144        }
    1120         if (conn) {
     1145        return NULL;
     1146}
     1147
     1148/****************************************************************************
     1149 Make a connection to a service from SMB1. Internal interface.
     1150****************************************************************************/
     1151
     1152static connection_struct *make_connection_smb1(struct smbd_server_connection *sconn,
     1153                                        int snum, user_struct *vuser,
     1154                                        DATA_BLOB password,
     1155                                        const char *pdev,
     1156                                        NTSTATUS *pstatus)
     1157{
     1158        connection_struct *ret_conn = NULL;
     1159        connection_struct *conn = conn_new(sconn);
     1160        if (!conn) {
     1161                DEBUG(0,("make_connection_smb1: Couldn't find free connection.\n"));
     1162                *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
     1163                return NULL;
     1164        }
     1165        ret_conn = make_connection_snum(sconn,
     1166                                        conn,
     1167                                        snum,
     1168                                        vuser,
     1169                                        password,
     1170                                        pdev,
     1171                                        pstatus);
     1172        if (ret_conn != conn) {
    11211173                conn_free(conn);
    1122         }
    1123         return NULL;
     1174                return NULL;
     1175        }
     1176        return conn;
    11241177}
    11251178
    11261179/****************************************************************************
    1127  Make a connection to a service.
     1180 Make a connection to a service from SMB2. External SMB2 interface.
     1181 We must set cnum before claiming connection.
     1182****************************************************************************/
     1183
     1184connection_struct *make_connection_smb2(struct smbd_server_connection *sconn,
     1185                                        struct smbd_smb2_tcon *tcon,
     1186                                        user_struct *vuser,
     1187                                        DATA_BLOB password,
     1188                                        const char *pdev,
     1189                                        NTSTATUS *pstatus)
     1190{
     1191        connection_struct *ret_conn = NULL;
     1192        connection_struct *conn = conn_new(sconn);
     1193        if (!conn) {
     1194                DEBUG(0,("make_connection_smb2: Couldn't find free connection.\n"));
     1195                *pstatus = NT_STATUS_INSUFFICIENT_RESOURCES;
     1196                return NULL;
     1197        }
     1198        conn->cnum = tcon->tid;
     1199        ret_conn = make_connection_snum(sconn,
     1200                                        conn,
     1201                                        tcon->snum,
     1202                                        vuser,
     1203                                        password,
     1204                                        pdev,
     1205                                        pstatus);
     1206        if (ret_conn != conn) {
     1207                conn_free(conn);
     1208                return NULL;
     1209        }
     1210        return conn;
     1211}
     1212
     1213/****************************************************************************
     1214 Make a connection to a service. External SMB1 interface.
    11281215 *
    11291216 * @param service
     
    11881275                        DEBUG(5, ("making a connection to [homes] service "
    11891276                                  "created at session setup time\n"));
    1190                         return make_connection_snum(sconn,
     1277                        return make_connection_smb1(sconn,
    11911278                                                    vuser->homes_snum,
    11921279                                                    vuser, no_pw,
     
    12121299                                          "service %s based on "
    12131300                                          "security=share\n", service_in));
    1214                                 return make_connection_snum(sconn,
     1301                                return make_connection_smb1(sconn,
    12151302                                                            snum, NULL,
    12161303                                                            password,
     
    12241311                DEBUG(5, ("making a connection to 'homes' service [%s] "
    12251312                          "created at session setup time\n", service_in));
    1226                 return make_connection_snum(sconn,
     1313                return make_connection_smb1(sconn,
    12271314                                            vuser->homes_snum,
    12281315                                            vuser, no_pw,
     
    12721359        DEBUG(5, ("making a connection to 'normal' service %s\n", service));
    12731360
    1274         return make_connection_snum(sconn, snum, vuser,
     1361        return make_connection_smb1(sconn, snum, vuser,
    12751362                                    password,
    12761363                                    dev, status);
Note: See TracChangeset for help on using the changeset viewer.