Ignore:
Timestamp:
Nov 12, 2012, 4:35:55 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server 3.5: update branche to 3.5.12

Location:
branches/samba-3.5.x/source3
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.5.x/source3/Makefile.in

    r599 r732  
    2929
    3030## Dynamic shared libraries build settings
    31 DSO_EXPORTS_CMD=-Wl,--version-script,$(srcdir)/exports/`basename $@ | sed 's/@SHLIBEXT@\(.[0-9]\{1,\}\)\{0,1\}$$/@SYMSEXT@/'`
     31DSO_EXPORTS_CMD=-Wl,--version-script,$(srcdir)/exports/`basename $@ | sed 's:\.@SHLIBEXT@[\.0-9]*$$:.@SYMSEXT@:'`
    3232DSO_EXPORTS=@DSO_EXPORTS@
    3333SHLD_DSO = $(SHLD) $(LDSHFLAGS) $(DSO_EXPORTS) -o $@
  • branches/samba-3.5.x/source3/VERSION

    r620 r732  
    2626SAMBA_VERSION_MAJOR=3
    2727SAMBA_VERSION_MINOR=5
    28 SAMBA_VERSION_RELEASE=11
     28SAMBA_VERSION_RELEASE=12
    2929
    3030########################################################
  • branches/samba-3.5.x/source3/build.cmd

    r698 r732  
    1515/* version 0.3.7 from 23.04.2012 Silvan (compile and link flags need to be
    1616                                         set here [happy birthday Jason]) */
     17/* version 0.3.8 from 09.11.2012 Silvan (eliminated the 2nd brand function) */
    1718                                         
    1819/* load the sysfuncs if not already loaded */
     
    2425
    2526/* init the version string (don't forget to change) */
    26 version = "0.3.7"
    27 version_date = "23.04.2012"
     27version = "0.3.8"
     28version_date = "09.11.2012"
    2829
    2930/* number of make jobs to execute at the same time */
     
    112113end
    113114
     115say "Building with: " || build_parms
     116say
    114117ok = SysFileTree(".\include\version.h",versionh.,'FO')
    115118
    116 if versionh.0 = 0 & conf = "YES" then do
     119if (versionh.0 = 0 & conf = "YES") | (brand = "YES") then do
    117120    svninfo = ".\svninfo"
    118121    address cmd 'svn status -q -u | grep "^Status against revision:" | sed -e "s/Status against revision: *//">'svninfo
     
    159162end
    160163
    161 if brand = "YES" then do
    162     svninfo = ".\svninfo"
    163     address cmd 'svn status -q -u | grep "^Status against revision:" | sed -e "s/Status against revision: *//">'svninfo
    164     revision = strip(translate(linein(svninfo)))
    165     ok = stream(svninfo,'c','close')
    166     call brand revision
    167 end
    168 
    169164if make <> "" then do
    170     say build_parms
    171165    address cmd 'make -j 'jobs' 2>&1 | tee build.log'
    172166end
     
    257251    ok = SysFileDelete(NewVersion)
    258252    verstring = suffix'-'Major'.'minor'.'release'.'revision'-'vendor'-'date('S')
    259     say "Samba "verstring
     253    say "Samba branded as: "verstring
     254    say
    260255return
    261256
  • branches/samba-3.5.x/source3/client/client.c

    r593 r732  
    16691669        if (!NT_STATUS_IS_OK(status)) {
    16701670                d_fprintf(stderr, "cli_push returned %s\n", nt_errstr(status));
     1671                rc = 1;
    16711672        }
    16721673
     
    17011702        if (f == x_stdin) {
    17021703                cli_shutdown(cli);
    1703                 exit(0);
     1704                exit(rc);
    17041705        }
    17051706
     
    23052306
    23062307        if (!NT_STATUS_IS_OK(cli_posix_open(targetcli, targetname, O_CREAT|O_RDWR, mode, &fnum))) {
    2307                 if (!NT_STATUS_IS_OK(cli_posix_open(targetcli, targetname, O_CREAT|O_RDONLY, mode, &fnum))) {
    2308                         d_printf("posix_open file %s: for read/write fnum %d\n", targetname, fnum);
     2308                if (NT_STATUS_IS_OK(cli_posix_open(targetcli, targetname, O_CREAT|O_RDONLY, mode, &fnum))) {
     2309                        d_printf("posix_open file %s: for readonly fnum %d\n", targetname, fnum);
    23092310                } else {
    23102311                        d_printf("Failed to open file %s. %s\n", targetname, cli_errstr(cli));
  • branches/samba-3.5.x/source3/include/local.h

    r599 r732  
    241241#define WINBIND_SERVER_MUTEX_WAIT_TIME (( ((NUM_CLI_AUTH_CONNECT_RETRIES) * ((CLI_AUTH_TIMEOUT)/1000)) + 5)*2)
    242242
    243 /* Max number of simultaneous winbindd socket connections. */
    244 #define WINBINDD_MAX_SIMULTANEOUS_CLIENTS 200
    245 
    246243/* Buffer size to use when printing backtraces */
    247244#define BACKTRACE_STACK_SIZE 64
  • branches/samba-3.5.x/source3/include/proto.h

    r599 r732  
    12431243                              struct tevent_context *ev,
    12441244                              NTSTATUS *status);
     1245bool is_executable(const char *fname);
     1246bool map_open_params_to_ntcreate(const char *smb_base_fname,
     1247                                 int deny_mode, int open_func,
     1248                                 uint32 *paccess_mask,
     1249                                 uint32 *pshare_mode,
     1250                                 uint32 *pcreate_disposition,
     1251                                 uint32 *pcreate_options);
    12451252
    12461253/* The following definitions come from lib/util_file.c  */
     
    42584265int lp_winbind_cache_time(void);
    42594266int lp_winbind_reconnect_delay(void);
     4267int lp_winbind_max_clients(void);
    42604268const char **lp_winbind_nss_info(void);
    42614269int lp_algorithmic_rid_base(void);
     
    63476355                      struct smb_filename **smb_fname,
    63486356                      uint32_t ucf_flags);
     6357NTSTATUS check_veto_path(connection_struct *conn, const char *name);
    63496358NTSTATUS check_name(connection_struct *conn, const char *name);
    63506359int get_real_filename(connection_struct *conn, const char *path,
     
    66096618                                    const char *fname,
    66106619                                    SMB_STRUCT_STAT *psbuf);
    6611 bool is_executable(const char *fname);
    66126620bool is_stat_open(uint32 access_mask);
    66136621bool request_timed_out(struct timeval request_time,
     
    66296637                         uint32 share_access,
    66306638                         uint32 create_options);
    6631 bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
    6632                                  int deny_mode, int open_func,
    6633                                  uint32 *paccess_mask,
    6634                                  uint32 *pshare_mode,
    6635                                  uint32 *pcreate_disposition,
    6636                                  uint32 *pcreate_options);
    66376639NTSTATUS open_file_fchmod(connection_struct *conn,
    66386640                          struct smb_filename *smb_fname,
     
    70547056                bool case_sensitive);
    70557057bool stat_cache_lookup(connection_struct *conn,
     7058                        bool posix_paths,
    70567059                        char **pp_name,
    70577060                        char **pp_dirpath,
  • branches/samba-3.5.x/source3/include/smb.h

    r480 r732  
    19581958#define UCF_COND_ALLOW_WCARD_LCOMP      0x00000004
    19591959#define UCF_POSIX_PATHNAMES             0x00000008
     1960#define UCF_UNIX_NAME_LOOKUP            0x00000010
    19601961
    19611962/*
  • branches/samba-3.5.x/source3/lib/netapi/netapi.c

    r414 r732  
    5656        NET_API_STATUS status;
    5757        struct libnetapi_ctx *ctx = NULL;
    58         char *krb5_cc_env = NULL;
    5958
    6059        if (stat_ctx && libnetapi_initialized) {
     
    101100
    102101        BlockSignals(True, SIGPIPE);
    103 
    104         krb5_cc_env = getenv(KRB5_ENV_CCNAME);
    105         if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) {
    106                 ctx->krb5_cc_env = talloc_strdup(frame, "MEMORY:libnetapi");
    107                 setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1);
    108         }
    109102
    110103        if (getenv("USER")) {
     
    251244}
    252245
     246/****************************************************************
     247****************************************************************/
     248
    253249NET_API_STATUS libnetapi_set_use_ccache(struct libnetapi_ctx *ctx)
    254250{
  • branches/samba-3.5.x/source3/lib/util.c

    r599 r732  
    30763076        return ret;
    30773077}
     3078
     3079/*******************************************************************
     3080 Return True if the filename is one of the special executable types.
     3081********************************************************************/
     3082
     3083bool is_executable(const char *fname)
     3084{
     3085        if ((fname = strrchr_m(fname,'.'))) {
     3086                if (strequal(fname,".com") ||
     3087                    strequal(fname,".dll") ||
     3088                    strequal(fname,".exe") ||
     3089                    strequal(fname,".sym")) {
     3090                        return True;
     3091                }
     3092        }
     3093        return False;
     3094}
     3095
     3096/****************************************************************************
     3097 Open a file with a share mode - old openX method - map into NTCreate.
     3098****************************************************************************/
     3099
     3100bool map_open_params_to_ntcreate(const char *smb_base_fname,
     3101                                 int deny_mode, int open_func,
     3102                                 uint32 *paccess_mask,
     3103                                 uint32 *pshare_mode,
     3104                                 uint32 *pcreate_disposition,
     3105                                 uint32 *pcreate_options)
     3106{
     3107        uint32 access_mask;
     3108        uint32 share_mode;
     3109        uint32 create_disposition;
     3110        uint32 create_options = FILE_NON_DIRECTORY_FILE;
     3111
     3112        DEBUG(10,("map_open_params_to_ntcreate: fname = %s, deny_mode = 0x%x, "
     3113                  "open_func = 0x%x\n",
     3114                  smb_base_fname, (unsigned int)deny_mode,
     3115                  (unsigned int)open_func ));
     3116
     3117        /* Create the NT compatible access_mask. */
     3118        switch (GET_OPENX_MODE(deny_mode)) {
     3119                case DOS_OPEN_EXEC: /* Implies read-only - used to be FILE_READ_DATA */
     3120                case DOS_OPEN_RDONLY:
     3121                        access_mask = FILE_GENERIC_READ;
     3122                        break;
     3123                case DOS_OPEN_WRONLY:
     3124                        access_mask = FILE_GENERIC_WRITE;
     3125                        break;
     3126                case DOS_OPEN_RDWR:
     3127                case DOS_OPEN_FCB:
     3128                        access_mask = FILE_GENERIC_READ|FILE_GENERIC_WRITE;
     3129                        break;
     3130                default:
     3131                        DEBUG(10,("map_open_params_to_ntcreate: bad open mode = 0x%x\n",
     3132                                  (unsigned int)GET_OPENX_MODE(deny_mode)));
     3133                        return False;
     3134        }
     3135
     3136        /* Create the NT compatible create_disposition. */
     3137        switch (open_func) {
     3138                case OPENX_FILE_EXISTS_FAIL|OPENX_FILE_CREATE_IF_NOT_EXIST:
     3139                        create_disposition = FILE_CREATE;
     3140                        break;
     3141
     3142                case OPENX_FILE_EXISTS_OPEN:
     3143                        create_disposition = FILE_OPEN;
     3144                        break;
     3145
     3146                case OPENX_FILE_EXISTS_OPEN|OPENX_FILE_CREATE_IF_NOT_EXIST:
     3147                        create_disposition = FILE_OPEN_IF;
     3148                        break;
     3149
     3150                case OPENX_FILE_EXISTS_TRUNCATE:
     3151                        create_disposition = FILE_OVERWRITE;
     3152                        break;
     3153
     3154                case OPENX_FILE_EXISTS_TRUNCATE|OPENX_FILE_CREATE_IF_NOT_EXIST:
     3155                        create_disposition = FILE_OVERWRITE_IF;
     3156                        break;
     3157
     3158                default:
     3159                        /* From samba4 - to be confirmed. */
     3160                        if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_EXEC) {
     3161                                create_disposition = FILE_CREATE;
     3162                                break;
     3163                        }
     3164                        DEBUG(10,("map_open_params_to_ntcreate: bad "
     3165                                  "open_func 0x%x\n", (unsigned int)open_func));
     3166                        return False;
     3167        }
     3168
     3169        /* Create the NT compatible share modes. */
     3170        switch (GET_DENY_MODE(deny_mode)) {
     3171                case DENY_ALL:
     3172                        share_mode = FILE_SHARE_NONE;
     3173                        break;
     3174
     3175                case DENY_WRITE:
     3176                        share_mode = FILE_SHARE_READ;
     3177                        break;
     3178
     3179                case DENY_READ:
     3180                        share_mode = FILE_SHARE_WRITE;
     3181                        break;
     3182
     3183                case DENY_NONE:
     3184                        share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
     3185                        break;
     3186
     3187                case DENY_DOS:
     3188                        create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
     3189                        if (is_executable(smb_base_fname)) {
     3190                                share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
     3191                        } else {
     3192                                if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_RDONLY) {
     3193                                        share_mode = FILE_SHARE_READ;
     3194                                } else {
     3195                                        share_mode = FILE_SHARE_NONE;
     3196                                }
     3197                        }
     3198                        break;
     3199
     3200                case DENY_FCB:
     3201                        create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
     3202                        share_mode = FILE_SHARE_NONE;
     3203                        break;
     3204
     3205                default:
     3206                        DEBUG(10,("map_open_params_to_ntcreate: bad deny_mode 0x%x\n",
     3207                                (unsigned int)GET_DENY_MODE(deny_mode) ));
     3208                        return False;
     3209        }
     3210
     3211        DEBUG(10,("map_open_params_to_ntcreate: file %s, access_mask = 0x%x, "
     3212                  "share_mode = 0x%x, create_disposition = 0x%x, "
     3213                  "create_options = 0x%x\n",
     3214                  smb_base_fname,
     3215                  (unsigned int)access_mask,
     3216                  (unsigned int)share_mode,
     3217                  (unsigned int)create_disposition,
     3218                  (unsigned int)create_options ));
     3219
     3220        if (paccess_mask) {
     3221                *paccess_mask = access_mask;
     3222        }
     3223        if (pshare_mode) {
     3224                *pshare_mode = share_mode;
     3225        }
     3226        if (pcreate_disposition) {
     3227                *pcreate_disposition = create_disposition;
     3228        }
     3229        if (pcreate_options) {
     3230                *pcreate_options = create_options;
     3231        }
     3232
     3233        return True;
     3234
     3235}
  • branches/samba-3.5.x/source3/libnet/libnet_join.c

    r599 r732  
    16211621static int libnet_destroy_JoinCtx(struct libnet_JoinCtx *r)
    16221622{
    1623         const char *krb5_cc_env = NULL;
    1624 
    16251623        if (r->in.ads) {
    16261624                ads_destroy(&r->in.ads);
    16271625        }
    16281626
    1629         krb5_cc_env = getenv(KRB5_ENV_CCNAME);
    1630         if (krb5_cc_env && StrCaseCmp(krb5_cc_env, "MEMORY:libnetjoin")) {
    1631                 unsetenv(KRB5_ENV_CCNAME);
    1632         }
    1633 
    16341627        return 0;
    16351628}
     
    16401633static int libnet_destroy_UnjoinCtx(struct libnet_UnjoinCtx *r)
    16411634{
    1642         const char *krb5_cc_env = NULL;
    1643 
    16441635        if (r->in.ads) {
    16451636                ads_destroy(&r->in.ads);
    16461637        }
    16471638
    1648         krb5_cc_env = getenv(KRB5_ENV_CCNAME);
    1649         if (krb5_cc_env && StrCaseCmp(krb5_cc_env, "MEMORY:libnetjoin")) {
    1650                 unsetenv(KRB5_ENV_CCNAME);
    1651         }
    1652 
    16531639        return 0;
    16541640}
     
    16611647{
    16621648        struct libnet_JoinCtx *ctx;
    1663         const char *krb5_cc_env = NULL;
    16641649
    16651650        ctx = talloc_zero(mem_ctx, struct libnet_JoinCtx);
     
    16731658        W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name);
    16741659
    1675         krb5_cc_env = getenv(KRB5_ENV_CCNAME);
    1676         if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) {
    1677                 krb5_cc_env = talloc_strdup(mem_ctx, "MEMORY:libnetjoin");
    1678                 W_ERROR_HAVE_NO_MEMORY(krb5_cc_env);
    1679                 setenv(KRB5_ENV_CCNAME, krb5_cc_env, 1);
    1680         }
    1681 
    16821660        ctx->in.secure_channel_type = SEC_CHAN_WKSTA;
    16831661
     
    16941672{
    16951673        struct libnet_UnjoinCtx *ctx;
    1696         const char *krb5_cc_env = NULL;
    16971674
    16981675        ctx = talloc_zero(mem_ctx, struct libnet_UnjoinCtx);
     
    17051682        ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname());
    17061683        W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name);
    1707 
    1708         krb5_cc_env = getenv(KRB5_ENV_CCNAME);
    1709         if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) {
    1710                 krb5_cc_env = talloc_strdup(mem_ctx, "MEMORY:libnetjoin");
    1711                 W_ERROR_HAVE_NO_MEMORY(krb5_cc_env);
    1712                 setenv(KRB5_ENV_CCNAME, krb5_cc_env, 1);
    1713         }
    17141684
    17151685        *r = ctx;
  • branches/samba-3.5.x/source3/libsmb/cliconnect.c

    r599 r732  
    10751075                        if (dest_realm) {
    10761076                                realm = SMB_STRDUP(dest_realm);
     1077                                if (!realm) {
     1078                                        return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
     1079                                }
    10771080                                strupper_m(realm);
    10781081                        } else {
     
    10861089                        }
    10871090
    1088                         if (realm && *realm) {
    1089                                 principal = talloc_asprintf(talloc_tos(),
    1090                                                             "cifs/%s@%s",
    1091                                                             cli->desthost,
    1092                                                             realm);
    1093                                 if (!principal) {
    1094                                         SAFE_FREE(realm);
     1091                        if (realm == NULL || *realm == '\0') {
     1092                                realm = SMB_STRDUP(lp_realm());
     1093                                if (!realm) {
    10951094                                        return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
    10961095                                }
    1097                                 DEBUG(3,("cli_session_setup_spnego: guessed "
    1098                                         "server principal=%s\n",
    1099                                         principal ? principal : "<null>"));
     1096                                strupper_m(realm);
     1097                                DEBUG(3,("cli_session_setup_spnego: cannot "
     1098                                        "get realm from dest_realm %s, "
     1099                                        "desthost %s. Using default "
     1100                                        "smb.conf realm %s\n",
     1101                                        dest_realm ? dest_realm : "<null>",
     1102                                        cli->desthost,
     1103                                        realm));
    11001104                        }
     1105
     1106                        principal = talloc_asprintf(talloc_tos(),
     1107                                                    "cifs/%s@%s",
     1108                                                    cli->desthost,
     1109                                                    realm);
     1110                        if (!principal) {
     1111                                SAFE_FREE(realm);
     1112                                return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
     1113                        }
     1114                        DEBUG(3,("cli_session_setup_spnego: guessed "
     1115                                "server principal=%s\n",
     1116                                principal ? principal : "<null>"));
     1117
    11011118                        SAFE_FREE(realm);
    11021119                }
     
    17001717                struct timespec ts;
    17011718                bool negotiated_smb_signing = false;
     1719
     1720                if (wct != 0x11) {
     1721                        tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
     1722                        return;
     1723                }
    17021724
    17031725                /* NT protocol */
     
    17661788
    17671789        } else if (cli->protocol >= PROTOCOL_LANMAN1) {
     1790                if (wct != 0x0D) {
     1791                        tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE);
     1792                        return;
     1793                }
     1794
    17681795                cli->use_spnego = False;
    17691796                cli->sec_mode = SVAL(vwv + 1, 0);
  • branches/samba-3.5.x/source3/libsmb/clifile.c

    r454 r732  
    21502150
    21512151struct cli_open_state {
     2152        struct tevent_context *ev;
     2153        struct cli_state *cli;
     2154        const char *fname;
    21522155        uint16_t vwv[15];
    21532156        uint16_t fnum;
     2157        unsigned openfn;
     2158        unsigned dos_deny;
     2159        uint8_t additional_flags;
    21542160        struct iovec bytes;
    21552161};
    21562162
    21572163static void cli_open_done(struct tevent_req *subreq);
     2164static void cli_open_ntcreate_done(struct tevent_req *subreq);
    21582165
    21592166struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
     
    21652172        struct tevent_req *req, *subreq;
    21662173        struct cli_open_state *state;
    2167         unsigned openfn;
    2168         unsigned accessmode;
    2169         uint8_t additional_flags;
    21702174        uint8_t *bytes;
    21712175
     
    21742178                return NULL;
    21752179        }
    2176 
    2177         openfn = 0;
     2180        state->ev = ev;
     2181        state->cli = cli;
     2182        state->fname = fname;
     2183
    21782184        if (flags & O_CREAT) {
    2179                 openfn |= (1<<4);
     2185                state->openfn |= (1<<4);
    21802186        }
    21812187        if (!(flags & O_EXCL)) {
    21822188                if (flags & O_TRUNC)
    2183                         openfn |= (1<<1);
     2189                        state->openfn |= (1<<1);
    21842190                else
    2185                         openfn |= (1<<0);
    2186         }
    2187 
    2188         accessmode = (share_mode<<4);
     2191                        state->openfn |= (1<<0);
     2192        }
     2193
     2194        state->dos_deny = (share_mode<<4);
    21892195
    21902196        if ((flags & O_ACCMODE) == O_RDWR) {
    2191                 accessmode |= 2;
     2197                state->dos_deny |= 2;
    21922198        } else if ((flags & O_ACCMODE) == O_WRONLY) {
    2193                 accessmode |= 1;
     2199                state->dos_deny |= 1;
    21942200        }
    21952201
    21962202#if defined(O_SYNC)
    21972203        if ((flags & O_SYNC) == O_SYNC) {
    2198                 accessmode |= (1<<14);
     2204                state->dos_deny |= (1<<14);
    21992205        }
    22002206#endif /* O_SYNC */
    22012207
    22022208        if (share_mode == DENY_FCB) {
    2203                 accessmode = 0xFF;
     2209                state->dos_deny = 0xFF;
    22042210        }
    22052211
     
    22082214        SSVAL(state->vwv + 1, 0, 0);
    22092215        SSVAL(state->vwv + 2, 0, 0);  /* no additional info */
    2210         SSVAL(state->vwv + 3, 0, accessmode);
     2216        SSVAL(state->vwv + 3, 0, state->dos_deny);
    22112217        SSVAL(state->vwv + 4, 0, aSYSTEM | aHIDDEN);
    22122218        SSVAL(state->vwv + 5, 0, 0);
    22132219        SIVAL(state->vwv + 6, 0, 0);
    2214         SSVAL(state->vwv + 8, 0, openfn);
     2220        SSVAL(state->vwv + 8, 0, state->openfn);
    22152221        SIVAL(state->vwv + 9, 0, 0);
    22162222        SIVAL(state->vwv + 11, 0, 0);
    22172223        SIVAL(state->vwv + 13, 0, 0);
    22182224
    2219         additional_flags = 0;
    2220 
    22212225        if (cli->use_oplocks) {
    22222226                /* if using oplocks then ask for a batch oplock via
    22232227                   core and extended methods */
    2224                 additional_flags =
     2228                state->additional_flags =
    22252229                        FLAG_REQUEST_OPLOCK|FLAG_REQUEST_BATCH_OPLOCK;
    22262230                SSVAL(state->vwv+2, 0, SVAL(state->vwv+2, 0) | 6);
     
    22382242        state->bytes.iov_len = talloc_get_size(bytes);
    22392243
    2240         subreq = cli_smb_req_create(state, ev, cli, SMBopenX, additional_flags,
     2244        subreq = cli_smb_req_create(state, ev, cli, SMBopenX,
     2245                                    state->additional_flags,
    22412246                                    15, state->vwv, 1, &state->bytes);
    22422247        if (subreq == NULL) {
     
    22792284        uint16_t *vwv;
    22802285        NTSTATUS status;
     2286        uint32_t access_mask, share_mode, create_disposition, create_options;
    22812287
    22822288        status = cli_smb_recv(subreq, 3, &wct, &vwv, NULL, NULL);
    2283         if (!NT_STATUS_IS_OK(status)) {
    2284                 TALLOC_FREE(subreq);
     2289        TALLOC_FREE(subreq);
     2290
     2291        if (NT_STATUS_IS_OK(status)) {
     2292                state->fnum = SVAL(vwv+2, 0);
     2293                tevent_req_done(req);
     2294                return;
     2295        }
     2296
     2297        if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
    22852298                tevent_req_nterror(req, status);
    22862299                return;
    22872300        }
    2288         state->fnum = SVAL(vwv+2, 0);
     2301
     2302        /*
     2303         * For the new shiny OS/X Lion SMB server, try a ntcreate
     2304         * fallback.
     2305         */
     2306
     2307        if (!map_open_params_to_ntcreate(state->fname, state->dos_deny,
     2308                                        state->openfn, &access_mask,
     2309                                        &share_mode, &create_disposition,
     2310                                        &create_options)) {
     2311                tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
     2312                return;
     2313        }
     2314
     2315        subreq = cli_ntcreate_send(state, state->ev, state->cli,
     2316                                state->fname, 0, access_mask,
     2317                                0, share_mode, create_disposition,
     2318                                create_options, 0);
     2319        if (tevent_req_nomem(subreq, req)) {
     2320                return;
     2321        }
     2322        tevent_req_set_callback(subreq, cli_open_ntcreate_done, req);
     2323}
     2324
     2325static void cli_open_ntcreate_done(struct tevent_req *subreq)
     2326{
     2327        struct tevent_req *req = tevent_req_callback_data(
     2328                subreq, struct tevent_req);
     2329        struct cli_open_state *state = tevent_req_data(
     2330                req, struct cli_open_state);
     2331        NTSTATUS status;
     2332
     2333        status = cli_ntcreate_recv(subreq, &state->fnum);
     2334        TALLOC_FREE(subreq);
     2335
     2336        if (!NT_STATUS_IS_OK(status)) {
     2337                tevent_req_nterror(req, status);
     2338                return;
     2339        }
    22892340        tevent_req_done(req);
    22902341}
  • branches/samba-3.5.x/source3/locking/locking.c

    r414 r732  
    13511351        if (fsp->is_directory) {
    13521352                SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
     1353
     1354                /* Or the root of a share. */
     1355                if (ISDOT(fsp->fsp_name->base_name)) {
     1356                        DEBUG(10,("can_set_delete_on_close: can't set delete on "
     1357                                  "close for the root of a share.\n"));
     1358                        return NT_STATUS_ACCESS_DENIED;
     1359                }
     1360
    13531361                return can_delete_directory(fsp->conn,
    13541362                                            fsp->fsp_name->base_name);
  • branches/samba-3.5.x/source3/modules/vfs_acl_common.c

    r599 r732  
    248248                                struct security_descriptor **ppdesc)
    249249{
    250         DATA_BLOB blob;
     250        DATA_BLOB blob = data_blob_null;
    251251        NTSTATUS status;
    252252        uint16_t hash_type;
     
    826826        struct smb_filename local_fname;
    827827        int saved_errno = 0;
     828        char *saved_dir = NULL;
     829
     830        saved_dir = vfs_GetWd(talloc_tos(),conn);
     831        if (!saved_dir) {
     832                saved_errno = errno;
     833                goto out;
     834        }
    828835
    829836        if (!parent_dirname(talloc_tos(), path,
     
    838845
    839846        /* cd into the parent dir to pin it. */
    840         ret = SMB_VFS_CHDIR(conn, parent_dir);
     847        ret = vfs_ChDir(conn, parent_dir);
    841848        if (ret == -1) {
    842849                saved_errno = errno;
     
    856863        /* Ensure we have this file open with DELETE access. */
    857864        id = vfs_file_id_from_sbuf(conn, &local_fname.st);
    858         for (fsp = file_find_di_first(id); fsp; file_find_di_next(fsp)) {
     865        for (fsp = file_find_di_first(id); fsp; fsp = file_find_di_next(fsp)) {
    859866                if (fsp->access_mask & DELETE_ACCESS &&
    860867                                fsp->delete_on_close) {
     
    891898        TALLOC_FREE(parent_dir);
    892899
    893         vfs_ChDir(conn, conn->connectpath);
     900        if (saved_dir) {
     901                vfs_ChDir(conn, saved_dir);
     902        }
    894903        if (saved_errno) {
    895904                errno = saved_errno;
  • branches/samba-3.5.x/source3/nmbd/nmbd_packets.c

    r620 r732  
    17161716                errno = EBADF;
    17171717                SAFE_FREE(pset);
     1718                SAFE_FREE(sock_array);
    17181719                return True;
    17191720        }
     
    17531754                errno = EBADF;
    17541755                SAFE_FREE(pset);
     1756                SAFE_FREE(sock_array);
    17551757                return True;
    17561758        }
  • branches/samba-3.5.x/source3/param/loadparm.c

    r690 r732  
    255255        int winbind_cache_time;
    256256        int winbind_reconnect_delay;
    257         int winbind_max_idle_children;
     257        int winbind_max_clients;
    258258        char **szWinbindNssInfo;
    259259        int iLockSpinTime;
     
    45564556        },
    45574557        {
     4558                .label          = "winbind max clients",
     4559                .type           = P_INTEGER,
     4560                .p_class        = P_GLOBAL,
     4561                .ptr            = &Globals.winbind_max_clients,
     4562                .special        = NULL,
     4563                .enum_list      = NULL,
     4564                .flags          = FLAG_ADVANCED,
     4565        },
     4566        {
    45584567                .label          = "winbind enum users",
    45594568                .type           = P_BOOL,
     
    52235232        Globals.winbind_cache_time = 300;       /* 5 minutes */
    52245233        Globals.winbind_reconnect_delay = 30;   /* 30 seconds */
     5234        Globals.winbind_max_clients = 200;
    52255235        Globals.bWinbindEnumUsers = False;
    52265236        Globals.bWinbindEnumGroups = False;
     
    57905800FN_GLOBAL_INTEGER(lp_winbind_cache_time, &Globals.winbind_cache_time)
    57915801FN_GLOBAL_INTEGER(lp_winbind_reconnect_delay, &Globals.winbind_reconnect_delay)
     5802FN_GLOBAL_INTEGER(lp_winbind_max_clients, &Globals.winbind_max_clients)
    57925803FN_GLOBAL_LIST(lp_winbind_nss_info, &Globals.szWinbindNssInfo)
    57935804FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
  • branches/samba-3.5.x/source3/rpc_server/srv_wkssvc_nt.c

    r414 r732  
    846846
    847847        become_root();
     848        setenv(KRB5_ENV_CCNAME, "MEMORY:_wkssvc_NetrJoinDomain2", 1);
    848849        werr = libnet_Join(p->mem_ctx, j);
     850        unsetenv(KRB5_ENV_CCNAME);
    849851        unbecome_root();
    850852
     
    912914
    913915        become_root();
     916        setenv(KRB5_ENV_CCNAME, "MEMORY:_wkssvc_NetrUnjoinDomain2", 1);
    914917        werr = libnet_Unjoin(p->mem_ctx, u);
     918        unsetenv(KRB5_ENV_CCNAME);
    915919        unbecome_root();
    916920
  • branches/samba-3.5.x/source3/smbd/filename.c

    r599 r732  
    296296        if((!conn->case_sensitive || !(conn->fs_capabilities &
    297297                                       FILE_CASE_SENSITIVE_SEARCH)) &&
    298             stat_cache_lookup(conn, &smb_fname->base_name, &dirpath, &start,
     298            stat_cache_lookup(conn, posix_pathnames, &smb_fname->base_name, &dirpath, &start,
    299299                              &smb_fname->st)) {
    300300                goto done;
     
    840840
    841841/****************************************************************************
     842 Ensure a path is not vetod.
     843****************************************************************************/
     844
     845NTSTATUS check_veto_path(connection_struct *conn, const char *name)
     846{
     847        if (IS_VETO_PATH(conn, name))  {
     848                /* Is it not dot or dot dot. */
     849                if (!(ISDOT(name) || ISDOTDOT(name))) {
     850                        DEBUG(5,("check_veto_path: file path name %s vetoed\n",
     851                                                name));
     852                        return map_nt_error_from_unix(ENOENT);
     853                }
     854        }
     855        return NT_STATUS_OK;
     856}
     857
     858/****************************************************************************
    842859 Check a filename - possibly calling check_reduced_name.
    843860 This is called by every routine before it allows an operation on a filename.
     
    848865NTSTATUS check_name(connection_struct *conn, const char *name)
    849866{
    850         if (IS_VETO_PATH(conn, name))  {
    851                 /* Is it not dot or dot dot. */
    852                 if (!((name[0] == '.') && (!name[1] ||
    853                                         (name[1] == '.' && !name[2])))) {
    854                         DEBUG(5,("check_name: file path name %s vetoed\n",
    855                                                 name));
    856                         return map_nt_error_from_unix(ENOENT);
    857                 }
     867        NTSTATUS status = check_veto_path(conn, name);
     868
     869        if (!NT_STATUS_IS_OK(status)) {
     870                return status;
    858871        }
    859872
    860873        if (!lp_widelinks(SNUM(conn)) || !lp_symlinks(SNUM(conn))) {
    861                 NTSTATUS status = check_reduced_name(conn,name);
     874                status = check_reduced_name(conn,name);
    862875                if (!NT_STATUS_IS_OK(status)) {
    863876                        DEBUG(5,("check_name: name %s failed with %s\n",name,
     
    11771190        }
    11781191
     1192        if ((ucf_flags & UCF_UNIX_NAME_LOOKUP) &&
     1193                        VALID_STAT((*pp_smb_fname)->st) &&
     1194                        S_ISLNK((*pp_smb_fname)->st.st_ex_mode)) {
     1195                return check_veto_path(conn, (*pp_smb_fname)->base_name);
     1196        }
     1197
    11791198        status = check_name(conn, (*pp_smb_fname)->base_name);
    11801199        if (!NT_STATUS_IS_OK(status)) {
  • branches/samba-3.5.x/source3/smbd/msdfs.c

    r596 r732  
    526526
    527527        /*
    528          * Note the unix path conversion here we're doing we can
     528         * Note the unix path conversion here we're doing we
    529529         * throw away. We're looking for a symlink for a dfs
    530530         * resolution, if we don't find it we'll do another
    531531         * unix_convert later in the codepath.
    532          * If we needed to remember what we'd resolved in
    533          * dp->reqpath (as the original code did) we'd
    534          * copy (localhost, dp->reqpath) on any code
    535          * path below that returns True - but I don't
    536          * think this is needed. JRA.
    537532         */
    538533
     
    545540                        return status;
    546541                }
    547 
    548                 /* Create an smb_fname to use below. */
    549                 status = create_synthetic_smb_fname(ctx, pdp->reqpath, NULL,
    550                                                     NULL, &smb_fname);
    551                 if (!NT_STATUS_IS_OK(status)) {
     542                if (smb_fname == NULL || smb_fname->base_name == NULL) {
    552543                        return status;
    553544                }
  • branches/samba-3.5.x/source3/smbd/nttrans.c

    r599 r732  
    861861        /* Ensure we have at least one thing set. */
    862862        if ((security_info_sent & (SECINFO_OWNER|SECINFO_GROUP|SECINFO_DACL|SECINFO_SACL)) == 0) {
     863                if (security_info_sent & SECINFO_LABEL) {
     864                        /* Only consider SECINFO_LABEL if no other
     865                           bits are set. Just like W2K3 we don't
     866                           store this. */
     867                        return NT_STATUS_OK;
     868                }
    863869                return NT_STATUS_INVALID_PARAMETER;
    864870        }
     
    18501856        }
    18511857
     1858        if (security_info_wanted & (SECINFO_DACL|SECINFO_OWNER|
     1859                        SECINFO_GROUP|SECINFO_SACL)) {
     1860                /* Don't return SECINFO_LABEL if anything else was
     1861                   requested. See bug #8458. */
     1862                security_info_wanted &= ~SECINFO_LABEL;
     1863        }
     1864
    18521865        if (!lp_nt_acl_support(SNUM(conn))) {
     1866                status = get_null_nt_acl(talloc_tos(), &psd);
     1867        } else if (security_info_wanted & SECINFO_LABEL) {
     1868                /* Like W2K3 return a null object. */
    18531869                status = get_null_nt_acl(talloc_tos(), &psd);
    18541870        } else {
     
    18821898            security_info_wanted & DACL_SECURITY_INFORMATION)
    18831899                psd->type |= SEC_DESC_DACL_PRESENT;
     1900
     1901        if (security_info_wanted & SECINFO_LABEL) {
     1902                /* Like W2K3 return a null object. */
     1903                psd->owner_sid = NULL;
     1904                psd->group_sid = NULL;
     1905                psd->dacl = NULL;
     1906                psd->sacl = NULL;
     1907                psd->type &= ~(SEC_DESC_DACL_PRESENT|SEC_DESC_SACL_PRESENT);
     1908        }
    18841909
    18851910        sd_size = ndr_size_security_descriptor(psd, NULL, 0);
  • branches/samba-3.5.x/source3/smbd/open.c

    r620 r732  
    661661}
    662662
    663 /*******************************************************************
    664  Return True if the filename is one of the special executable types.
    665 ********************************************************************/
    666 
    667 bool is_executable(const char *fname)
    668 {
    669         if ((fname = strrchr_m(fname,'.'))) {
    670                 if (strequal(fname,".com") ||
    671                     strequal(fname,".dll") ||
    672                     strequal(fname,".exe") ||
    673                     strequal(fname,".sym")) {
    674                         return True;
    675                 }
    676         }
    677         return False;
    678 }
    679 
    680663/****************************************************************************
    681664 Check if we can open a file with a share mode.
     
    12211204        return dup_file_fsp(req, fsp, access_mask, share_access,
    12221205                            create_options, fsp_to_dup_into);
    1223 }
    1224 
    1225 /****************************************************************************
    1226  Open a file with a share mode - old openX method - map into NTCreate.
    1227 ****************************************************************************/
    1228 
    1229 bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
    1230                                  int deny_mode, int open_func,
    1231                                  uint32 *paccess_mask,
    1232                                  uint32 *pshare_mode,
    1233                                  uint32 *pcreate_disposition,
    1234                                  uint32 *pcreate_options)
    1235 {
    1236         uint32 access_mask;
    1237         uint32 share_mode;
    1238         uint32 create_disposition;
    1239         uint32 create_options = FILE_NON_DIRECTORY_FILE;
    1240 
    1241         DEBUG(10,("map_open_params_to_ntcreate: fname = %s, deny_mode = 0x%x, "
    1242                   "open_func = 0x%x\n",
    1243                   smb_fname_str_dbg(smb_fname), (unsigned int)deny_mode,
    1244                   (unsigned int)open_func ));
    1245 
    1246         /* Create the NT compatible access_mask. */
    1247         switch (GET_OPENX_MODE(deny_mode)) {
    1248                 case DOS_OPEN_EXEC: /* Implies read-only - used to be FILE_READ_DATA */
    1249                 case DOS_OPEN_RDONLY:
    1250                         access_mask = FILE_GENERIC_READ;
    1251                         break;
    1252                 case DOS_OPEN_WRONLY:
    1253                         access_mask = FILE_GENERIC_WRITE;
    1254                         break;
    1255                 case DOS_OPEN_RDWR:
    1256                 case DOS_OPEN_FCB:
    1257                         access_mask = FILE_GENERIC_READ|FILE_GENERIC_WRITE;
    1258                         break;
    1259                 default:
    1260                         DEBUG(10,("map_open_params_to_ntcreate: bad open mode = 0x%x\n",
    1261                                   (unsigned int)GET_OPENX_MODE(deny_mode)));
    1262                         return False;
    1263         }
    1264 
    1265         /* Create the NT compatible create_disposition. */
    1266         switch (open_func) {
    1267                 case OPENX_FILE_EXISTS_FAIL|OPENX_FILE_CREATE_IF_NOT_EXIST:
    1268                         create_disposition = FILE_CREATE;
    1269                         break;
    1270 
    1271                 case OPENX_FILE_EXISTS_OPEN:
    1272                         create_disposition = FILE_OPEN;
    1273                         break;
    1274 
    1275                 case OPENX_FILE_EXISTS_OPEN|OPENX_FILE_CREATE_IF_NOT_EXIST:
    1276                         create_disposition = FILE_OPEN_IF;
    1277                         break;
    1278        
    1279                 case OPENX_FILE_EXISTS_TRUNCATE:
    1280                         create_disposition = FILE_OVERWRITE;
    1281                         break;
    1282 
    1283                 case OPENX_FILE_EXISTS_TRUNCATE|OPENX_FILE_CREATE_IF_NOT_EXIST:
    1284                         create_disposition = FILE_OVERWRITE_IF;
    1285                         break;
    1286 
    1287                 default:
    1288                         /* From samba4 - to be confirmed. */
    1289                         if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_EXEC) {
    1290                                 create_disposition = FILE_CREATE;
    1291                                 break;
    1292                         }
    1293                         DEBUG(10,("map_open_params_to_ntcreate: bad "
    1294                                   "open_func 0x%x\n", (unsigned int)open_func));
    1295                         return False;
    1296         }
    1297  
    1298         /* Create the NT compatible share modes. */
    1299         switch (GET_DENY_MODE(deny_mode)) {
    1300                 case DENY_ALL:
    1301                         share_mode = FILE_SHARE_NONE;
    1302                         break;
    1303 
    1304                 case DENY_WRITE:
    1305                         share_mode = FILE_SHARE_READ;
    1306                         break;
    1307 
    1308                 case DENY_READ:
    1309                         share_mode = FILE_SHARE_WRITE;
    1310                         break;
    1311 
    1312                 case DENY_NONE:
    1313                         share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
    1314                         break;
    1315 
    1316                 case DENY_DOS:
    1317                         create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
    1318                         if (is_executable(smb_fname->base_name)) {
    1319                                 share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
    1320                         } else {
    1321                                 if (GET_OPENX_MODE(deny_mode) == DOS_OPEN_RDONLY) {
    1322                                         share_mode = FILE_SHARE_READ;
    1323                                 } else {
    1324                                         share_mode = FILE_SHARE_NONE;
    1325                                 }
    1326                         }
    1327                         break;
    1328 
    1329                 case DENY_FCB:
    1330                         create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
    1331                         share_mode = FILE_SHARE_NONE;
    1332                         break;
    1333 
    1334                 default:
    1335                         DEBUG(10,("map_open_params_to_ntcreate: bad deny_mode 0x%x\n",
    1336                                 (unsigned int)GET_DENY_MODE(deny_mode) ));
    1337                         return False;
    1338         }
    1339 
    1340         DEBUG(10,("map_open_params_to_ntcreate: file %s, access_mask = 0x%x, "
    1341                   "share_mode = 0x%x, create_disposition = 0x%x, "
    1342                   "create_options = 0x%x\n",
    1343                   smb_fname_str_dbg(smb_fname),
    1344                   (unsigned int)access_mask,
    1345                   (unsigned int)share_mode,
    1346                   (unsigned int)create_disposition,
    1347                   (unsigned int)create_options ));
    1348 
    1349         if (paccess_mask) {
    1350                 *paccess_mask = access_mask;
    1351         }
    1352         if (pshare_mode) {
    1353                 *pshare_mode = share_mode;
    1354         }
    1355         if (pcreate_disposition) {
    1356                 *pcreate_disposition = create_disposition;
    1357         }
    1358         if (pcreate_options) {
    1359                 *pcreate_options = create_options;
    1360         }
    1361 
    1362         return True;
    1363 
    13641206}
    13651207
     
    15031345        ZERO_STRUCT(id);
    15041346
    1505         /* Windows allows a new file to be created and
    1506            silently removes a FILE_ATTRIBUTE_DIRECTORY
    1507            sent by the client. Do the same. */
    1508 
    1509         new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
    1510 
    15111347        if (conn->printer) {
    15121348                /*
     
    15421378                new_dos_attributes = 0;
    15431379        } else {
     1380                /* Windows allows a new file to be created and
     1381                   silently removes a FILE_ATTRIBUTE_DIRECTORY
     1382                   sent by the client. Do the same. */
     1383
     1384                new_dos_attributes &= ~FILE_ATTRIBUTE_DIRECTORY;
     1385
    15441386                /* We add aARCH to this as this mode is only used if the file is
    15451387                 * created new. */
  • branches/samba-3.5.x/source3/smbd/posix_acls.c

    r599 r732  
    13981398                pace->trustee = *pfile_owner_sid;
    13991399                pace->attr = ALLOW_ACE;
     1400                /* Start with existing permissions, principle of least
     1401                   surprises for the user. */
     1402                pace->perms = pst->st_ex_mode;
    14001403
    14011404                if (setting_acl) {
    14021405                        /* See if the owning user is in any of the other groups in
    1403                            the ACE. If so, OR in the permissions from that group. */
    1404 
    1405                         bool group_matched = False;
     1406                           the ACE, or if there's a matching user entry.
     1407                           If so, OR in the permissions from that entry. */
     1408
    14061409                        canon_ace *pace_iter;
    14071410
    14081411                        for (pace_iter = *pp_ace; pace_iter; pace_iter = pace_iter->next) {
    1409                                 if (pace_iter->type == SMB_ACL_GROUP_OBJ || pace_iter->type == SMB_ACL_GROUP) {
     1412                                if (pace_iter->type == SMB_ACL_USER &&
     1413                                                pace_iter->unix_ug.uid == pace->unix_ug.uid) {
     1414                                        pace->perms |= pace_iter->perms;
     1415                                } else if (pace_iter->type == SMB_ACL_GROUP_OBJ || pace_iter->type == SMB_ACL_GROUP) {
    14101416                                        if (uid_entry_in_group(pace, pace_iter)) {
    14111417                                                pace->perms |= pace_iter->perms;
    1412                                                 group_matched = True;
    14131418                                        }
    14141419                                }
    14151420                        }
    14161421
    1417                         /* If we only got an "everyone" perm, just use that. */
    1418                         if (!group_matched) {
     1422                        if (pace->perms == 0) {
     1423                                /* If we only got an "everyone" perm, just use that. */
    14191424                                if (got_other)
    14201425                                        pace->perms = pace_other->perms;
    1421                                 else
    1422                                         pace->perms = 0;
    14231426                        }
    14241427
     
    14851488 If it does not have them, check if there are any entries where the trustee is the
    14861489 file owner or the owning group, and map these to SMB_ACL_USER_OBJ and SMB_ACL_GROUP_OBJ.
     1490 Note we must not do this to default directory ACLs.
    14871491****************************************************************************/
    14881492
     
    15241528        if (!got_group_obj)
    15251529                DEBUG(10,("check_owning_objs: ACL is missing an owning group entry.\n"));
    1526 }
    1527 
    1528 /****************************************************************************
    1529  If an ACE entry is SMB_ACL_USER_OBJ and not CREATOR_OWNER, map to SMB_ACL_USER.
    1530  If an ACE entry is SMB_ACL_GROUP_OBJ and not CREATOR_GROUP, map to SMB_ACL_GROUP
    1531 ****************************************************************************/
    1532 
    1533 static bool dup_owning_ace(canon_ace *dir_ace, canon_ace *ace)
    1534 {
    1535         /* dir ace must be followings.
    1536            SMB_ACL_USER_OBJ : trustee(CREATOR_OWNER) -> Posix ACL d:u::perm
    1537            SMB_ACL_USER     : not trustee    -> Posix ACL u:user:perm
    1538            SMB_ACL_USER_OBJ : trustee -> convert to SMB_ACL_USER : trustee
    1539            Posix ACL u:trustee:perm
    1540 
    1541            SMB_ACL_GROUP_OBJ: trustee(CREATOR_GROUP) -> Posix ACL d:g::perm
    1542            SMB_ACL_GROUP    : not trustee   -> Posix ACL g:group:perm
    1543            SMB_ACL_GROUP_OBJ: trustee -> convert to SMB_ACL_GROUP : trustee
    1544            Posix ACL g:trustee:perm
    1545         */
    1546 
    1547         if (ace->type == SMB_ACL_USER_OBJ &&
    1548                         !(sid_equal(&ace->trustee, &global_sid_Creator_Owner))) {
    1549                 canon_ace *dup_ace = dup_canon_ace(ace);
    1550 
    1551                 if (dup_ace == NULL) {
    1552                         return false;
    1553                 }
    1554                 dup_ace->type = SMB_ACL_USER;
    1555                 DLIST_ADD_END(dir_ace, dup_ace, canon_ace *);
    1556         }
    1557 
    1558         if (ace->type == SMB_ACL_GROUP_OBJ &&
    1559                         !(sid_equal(&ace->trustee, &global_sid_Creator_Group))) {
    1560                 canon_ace *dup_ace = dup_canon_ace(ace);
    1561 
    1562                 if (dup_ace == NULL) {
    1563                         return false;
    1564                 }
    1565                 dup_ace->type = SMB_ACL_GROUP;
    1566                 DLIST_ADD_END(dir_ace, dup_ace, canon_ace *);
    1567         }
    1568 
    1569         return true;
    15701530}
    15711531
     
    17931753                                (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT)) {
    17941754
     1755                                canon_ace *current_dir_ace = current_ace;
    17951756                                DLIST_ADD_END(dir_ace, current_ace, canon_ace *);
    17961757
     
    18181779                                        dbgtext("create_canon_ace_lists: adding dir ACL:\n");
    18191780                                        print_canon_ace( current_ace, 0);
    1820                                 }
    1821 
    1822                                 /*
    1823                                  * We have a lossy mapping: directory ACE entries
    1824                                  * CREATOR_OWNER ------\
    1825                                  *     (map to)         +---> SMB_ACL_USER_OBJ
    1826                                  * owning sid    ------/
    1827                                  *
    1828                                  * CREATOR_GROUP ------\
    1829                                  *     (map to)         +---> SMB_ACL_GROUP_OBJ
    1830                                  * primary group sid --/
    1831                                  *
    1832                                  * on set. And on read of a directory ACL
    1833                                  *
    1834                                  * SMB_ACL_USER_OBJ ----> CREATOR_OWNER
    1835                                  * SMB_ACL_GROUP_OBJ ---> CREATOR_GROUP.
    1836                                  *
    1837                                  * Deal with this on set by duplicating
    1838                                  * owning sid and primary group sid ACE
    1839                                  * entries into the directory ACL.
    1840                                  * Fix from Tsukasa Hamano <hamano@osstech.co.jp>.
    1841                                  */
    1842 
    1843                                 if (!dup_owning_ace(dir_ace, current_ace)) {
    1844                                         DEBUG(0,("create_canon_ace_lists: malloc fail !\n"));
    1845                                         free_canon_ace_list(file_ace);
    1846                                         free_canon_ace_list(dir_ace);
    1847                                         return false;
    18481781                                }
    18491782
     
    18821815                                        current_ace = NULL;
    18831816                                }
     1817
     1818                                /*
     1819                                 * current_ace is now either owned by file_ace
     1820                                 * or is NULL. We can safely operate on current_dir_ace
     1821                                 * to treat mapping for default acl entries differently
     1822                                 * than access acl entries.
     1823                                 */
     1824
     1825                                if (current_dir_ace->owner_type == UID_ACE) {
     1826                                        /*
     1827                                         * We already decided above this is a uid,
     1828                                         * for default acls ace's only CREATOR_OWNER
     1829                                         * maps to ACL_USER_OBJ. All other uid
     1830                                         * ace's are ACL_USER.
     1831                                         */
     1832                                        if (sid_equal(&current_dir_ace->trustee,
     1833                                                        &global_sid_Creator_Owner)) {
     1834                                                current_dir_ace->type = SMB_ACL_USER_OBJ;
     1835                                        } else {
     1836                                                current_dir_ace->type = SMB_ACL_USER;
     1837                                        }
     1838                                }
     1839
     1840                                if (current_dir_ace->owner_type == GID_ACE) {
     1841                                        /*
     1842                                         * We already decided above this is a gid,
     1843                                         * for default acls ace's only CREATOR_GROUP
     1844                                         * maps to ACL_GROUP_OBJ. All other uid
     1845                                         * ace's are ACL_GROUP.
     1846                                         */
     1847                                        if (sid_equal(&current_dir_ace->trustee,
     1848                                                        &global_sid_Creator_Group)) {
     1849                                                current_dir_ace->type = SMB_ACL_GROUP_OBJ;
     1850                                        } else {
     1851                                                current_dir_ace->type = SMB_ACL_GROUP;
     1852                                        }
     1853                                }
    18841854                        }
    18851855                }
     
    19431913        } else {
    19441914                /*
    1945                  * Check if we have SMB_ACL_USER_OBJ and SMB_ACL_GROUP_OBJ entries in each
    1946                  * ACL. If we don't have them, check if any SMB_ACL_USER/SMB_ACL_GROUP
    1947                  * entries can be converted to *_OBJ. Usually we will already have these
    1948                  * entries in the Default ACL, and the Access ACL will not have them.
     1915                 * Check if we have SMB_ACL_USER_OBJ and SMB_ACL_GROUP_OBJ entries in
     1916                 * the file ACL. If we don't have them, check if any SMB_ACL_USER/SMB_ACL_GROUP
     1917                 * entries can be converted to *_OBJ. Don't do this for the default
     1918                 * ACL, we will create them separately for this if needed inside
     1919                 * ensure_canon_entry_valid().
    19491920                 */
    19501921                if (file_ace) {
    19511922                        check_owning_objs(file_ace, pfile_owner_sid, pfile_grp_sid);
    1952                 }
    1953                 if (dir_ace) {
    1954                         check_owning_objs(dir_ace, pfile_owner_sid, pfile_grp_sid);
    19551923                }
    19561924        }
     
    22752243
    22762244/****************************************************************************
    2277  Create a default mode that will be used if a security descriptor entry has
    2278  no user/group/world entries.
    2279 ****************************************************************************/
    2280 
    2281 static mode_t create_default_mode(files_struct *fsp, bool interitable_mode)
    2282 {
    2283         int snum = SNUM(fsp->conn);
    2284         mode_t and_bits = (mode_t)0;
    2285         mode_t or_bits = (mode_t)0;
    2286         mode_t mode;
    2287 
    2288         if (interitable_mode) {
    2289                 mode = unix_mode(fsp->conn, FILE_ATTRIBUTE_ARCHIVE,
    2290                                  fsp->fsp_name, NULL);
    2291         } else {
    2292                 mode = S_IRUSR;
    2293         }
    2294 
    2295         if (fsp->is_directory)
    2296                 mode |= (S_IWUSR|S_IXUSR);
    2297 
    2298         /*
    2299          * Now AND with the create mode/directory mode bits then OR with the
    2300          * force create mode/force directory mode bits.
    2301          */
    2302 
    2303         if (fsp->is_directory) {
    2304                 and_bits = lp_dir_security_mask(snum);
    2305                 or_bits = lp_force_dir_security_mode(snum);
    2306         } else {
    2307                 and_bits = lp_security_mask(snum);
    2308                 or_bits = lp_force_security_mode(snum);
    2309         }
    2310 
    2311         return ((mode & and_bits)|or_bits);
    2312 }
    2313 
    2314 /****************************************************************************
    23152245 Unpack a SEC_DESC into two canonical ace lists. We don't depend on this
    23162246 succeeding.
     
    23262256                                const SEC_DESC *psd)
    23272257{
    2328         SMB_STRUCT_STAT st;
    23292258        canon_ace *file_ace = NULL;
    23302259        canon_ace *dir_ace = NULL;
     
    23902319        print_canon_ace_list( "file ace - before valid", file_ace);
    23912320
    2392         st = *pst;
    2393 
    2394         /*
    2395          * A default 3 element mode entry for a file should be r-- --- ---.
    2396          * A default 3 element mode entry for a directory should be rwx --- ---.
    2397          */
    2398 
    2399         st.st_ex_mode = create_default_mode(fsp, False);
    2400 
    24012321        if (!ensure_canon_entry_valid(&file_ace, fsp->conn->params,
    2402                         fsp->is_directory, pfile_owner_sid, pfile_grp_sid, &st, True)) {
     2322                        fsp->is_directory, pfile_owner_sid, pfile_grp_sid, pst, True)) {
    24032323                free_canon_ace_list(file_ace);
    24042324                free_canon_ace_list(dir_ace);
     
    24082328        print_canon_ace_list( "dir ace - before valid", dir_ace);
    24092329
    2410         /*
    2411          * A default inheritable 3 element mode entry for a directory should be the
    2412          * mode Samba will use to create a file within. Ensure user rwx bits are set if
    2413          * it's a directory.
    2414          */
    2415 
    2416         st.st_ex_mode = create_default_mode(fsp, True);
    2417 
    24182330        if (dir_ace && !ensure_canon_entry_valid(&dir_ace, fsp->conn->params,
    2419                         fsp->is_directory, pfile_owner_sid, pfile_grp_sid, &st, True)) {
     2331                        fsp->is_directory, pfile_owner_sid, pfile_grp_sid, pst, True)) {
    24202332                free_canon_ace_list(file_ace);
    24212333                free_canon_ace_list(dir_ace);
  • branches/samba-3.5.x/source3/smbd/process.c

    r599 r732  
    19101910
    19111911        /*
    1912          * Check if the client tries to fool us. The request so far uses the
    1913          * space to the end of the byte buffer in the request just
    1914          * processed. The chain_offset can't point into that area. If that was
    1915          * the case, we could end up with an endless processing of the chain,
    1916          * we would always handle the same request.
    1917          */
    1918 
    1919         already_used = PTR_DIFF(req->buf+req->buflen, smb_base(req->inbuf));
    1920         if (chain_offset < already_used) {
     1912         * Check if the client tries to fool us. The chain offset
     1913         * needs to point beyond the current request in the chain, it
     1914         * needs to strictly grow. Otherwise we might be tricked into
     1915         * an endless loop always processing the same request over and
     1916         * over again. We used to assume that vwv and the byte buffer
     1917         * array in a chain are always attached, but OS/2 the
     1918         * Write&X/Read&X chain puts the Read&X vwv array right behind
     1919         * the Write&X vwv chain. The Write&X bcc array is put behind
     1920         * the Read&X vwv array. So now we check whether the chain
     1921         * offset points strictly behind the previous vwv
     1922         * array. req->buf points right after the vwv array of the
     1923         * previous request. See
     1924         * https://bugzilla.samba.org/show_bug.cgi?id=8360 for more
     1925         * information.
     1926         */
     1927
     1928        already_used = PTR_DIFF(req->buf, smb_base(req->inbuf));
     1929        if (chain_offset <= already_used) {
    19211930                goto error;
    19221931        }
  • branches/samba-3.5.x/source3/smbd/reply.c

    r590 r732  
    17541754        }
    17551755
    1756         if (!map_open_params_to_ntcreate(smb_fname, deny_mode,
     1756        if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,
    17571757                                         OPENX_FILE_EXISTS_OPEN, &access_mask,
    17581758                                         &share_mode, &create_disposition,
     
    19271927        }
    19281928
    1929         if (!map_open_params_to_ntcreate(smb_fname, deny_mode, smb_ofun,
     1929        if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,
     1930                                         smb_ofun,
    19301931                                         &access_mask, &share_mode,
    19311932                                         &create_disposition,
     
    64366437                new_create_disposition = FILE_OPEN;
    64376438        } else {
    6438                 if (!map_open_params_to_ntcreate(smb_fname_dst_tmp, 0, ofun,
     6439                if (!map_open_params_to_ntcreate(smb_fname_dst_tmp->base_name,
     6440                                                 0, ofun,
    64396441                                                 NULL, NULL,
    64406442                                                 &new_create_disposition,
  • branches/samba-3.5.x/source3/smbd/statcache.c

    r414 r732  
    146146 *
    147147 * @param conn    A connection struct to do the stat() with.
     148 * @param posix_paths Whether to lookup using stat() or lstat()
    148149 * @param name    The path we are attempting to cache, modified by this routine
    149150 *                to be correct as far as the cache can tell us. We assume that
     
    162163
    163164bool stat_cache_lookup(connection_struct *conn,
     165                        bool posix_paths,
    164166                        char **pp_name,
    165167                        char **pp_dirpath,
     
    177179        TALLOC_CTX *ctx = talloc_tos();
    178180        struct smb_filename smb_fname;
     181        int ret;
    179182
    180183        *pp_dirpath = NULL;
     
    279282        smb_fname.base_name = translated_path;
    280283
    281         if (SMB_VFS_STAT(conn, &smb_fname) != 0) {
     284        if (posix_paths) {
     285                ret = SMB_VFS_LSTAT(conn, &smb_fname);
     286        } else {
     287                ret = SMB_VFS_STAT(conn, &smb_fname);
     288        }
     289
     290        if (ret != 0) {
    282291                /* Discard this entry - it doesn't exist in the filesystem. */
    283292                memcache_delete(smbd_memcache(), STAT_CACHE,
  • branches/samba-3.5.x/source3/smbd/trans2.c

    r599 r732  
    10821082        }
    10831083
    1084         if (!map_open_params_to_ntcreate(smb_fname, deny_mode, open_ofun,
     1084        if (!map_open_params_to_ntcreate(smb_fname->base_name, deny_mode,
     1085                                         open_ofun,
    10851086                                         &access_mask, &share_mode,
    10861087                                         &create_disposition,
     
    22462247        struct dptr_struct *dirptr = NULL;
    22472248        struct smbd_server_connection *sconn = smbd_server_conn;
     2249        uint32_t ucf_flags = (UCF_SAVE_LCOMP | UCF_ALWAYS_ALLOW_WCARD_LCOMP);
    22482250
    22492251        if (total_params < 13) {
     
    22892291                                goto out;
    22902292                        }
     2293                        ucf_flags |= UCF_UNIX_NAME_LOOKUP;
    22912294                        break;
    22922295                default:
     
    23062309                                    req->flags2 & FLAGS2_DFS_PATHNAMES,
    23072310                                    directory,
    2308                                     (UCF_SAVE_LCOMP |
    2309                                         UCF_ALWAYS_ALLOW_WCARD_LCOMP),
     2311                                    ucf_flags,
    23102312                                    &mask_contains_wcard,
    23112313                                    &smb_dname);
     
    51025104        } else {
    51035105                char *fname = NULL;
     5106                uint32_t ucf_flags = 0;
    51045107
    51055108                /* qpathinfo */
     
    51135116                DEBUG(3,("call_trans2qfilepathinfo: TRANSACT2_QPATHINFO: level = %d\n", info_level));
    51145117
    5115                 if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
    5116                         reply_nterror(req, NT_STATUS_INVALID_LEVEL);
    5117                         return;
     5118                if (INFO_LEVEL_IS_UNIX(info_level)) {
     5119                        if (!lp_unix_extensions()) {
     5120                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
     5121                                return;
     5122                        }
     5123                        if (info_level == SMB_QUERY_FILE_UNIX_BASIC ||
     5124                                        info_level == SMB_QUERY_FILE_UNIX_INFO2 ||
     5125                                        info_level == SMB_QUERY_FILE_UNIX_LINK) {
     5126                                ucf_flags |= UCF_UNIX_NAME_LOOKUP;
     5127                        }
    51185128                }
    51195129
     
    51305140                                        req->flags2 & FLAGS2_DFS_PATHNAMES,
    51315141                                        fname,
    5132                                         0,
     5142                                        ucf_flags,
    51335143                                        NULL,
    51345144                                        &smb_fname);
  • branches/samba-3.5.x/source3/web/swat.c

    r617 r732  
    169169
    170170                snprintf(tmp, sizeof(tmp), "%02x", token[i]);
    171                 strncat(token_str, tmp, sizeof(tmp));
     171                strlcat(token_str, tmp, sizeof(tmp));
    172172        }
    173173}
     
    193193        const char *token = cgi_variable_nonull(XSRF_TOKEN);
    194194        const char *time_str = cgi_variable_nonull(XSRF_TIME);
     195        char *p = NULL;
     196        long long xsrf_time_ll = 0;
    195197        time_t xsrf_time = 0;
    196198        time_t now = time(NULL);
    197199
    198         if (sizeof(time_t) == sizeof(int)) {
    199                 xsrf_time = atoi(time_str);
    200         } else if (sizeof(time_t) == sizeof(long)) {
    201                 xsrf_time = atol(time_str);
    202         } else if (sizeof(time_t) == sizeof(long long)) {
    203                 xsrf_time = atoll(time_str);
    204         }
     200        errno = 0;
     201        xsrf_time_ll = strtoll(time_str, &p, 10);
     202        if (errno != 0) {
     203                return false;
     204        }
     205        if (p == NULL) {
     206                return false;
     207        }
     208        if (PTR_DIFF(p, time_str) > strlen(time_str)) {
     209                return false;
     210        }
     211        if (xsrf_time_ll > _TYPE_MAXIMUM(time_t)) {
     212                return false;
     213        }
     214        if (xsrf_time_ll < _TYPE_MINIMUM(time_t)) {
     215                return false;
     216        }
     217        xsrf_time = xsrf_time_ll;
    205218
    206219        if (abs(now - xsrf_time) > XSRF_TIMEOUT) {
  • branches/samba-3.5.x/source3/winbindd/wb_group_members.c

    r414 r732  
    214214
    215215        if (!NT_STATUS_IS_OK(status)) {
    216                 tevent_req_nterror(req, status);
    217                 return;
     216                if (!NT_STATUS_EQUAL(
     217                            status, NT_STATUS_TRUSTED_DOMAIN_FAILURE)) {
     218                        tevent_req_nterror(req, status);
     219                        return;
     220                }
     221                num_members = 0;
    218222        }
    219223
  • branches/samba-3.5.x/source3/winbindd/winbindd.c

    r599 r732  
    904904                                          struct winbindd_listen_state);
    905905
    906         while (winbindd_num_clients() >
    907                WINBINDD_MAX_SIMULTANEOUS_CLIENTS - 1) {
     906        while (winbindd_num_clients() > lp_winbind_max_clients() - 1) {
    908907                DEBUG(5,("winbindd: Exceeding %d client "
    909908                         "connections, removing idle "
    910                          "connection.\n",
    911                          WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
     909                         "connection.\n", lp_winbind_max_clients()));
    912910                if (!remove_idle_client()) {
    913911                        DEBUG(0,("winbindd: Exceeding %d "
    914912                                 "client connections, no idle "
    915913                                 "connection found\n",
    916                                  WINBINDD_MAX_SIMULTANEOUS_CLIENTS));
     914                                 lp_winbind_max_clients()));
    917915                        break;
    918916                }
  • branches/samba-3.5.x/source3/winbindd/winbindd_dual.c

    r593 r732  
    135135        struct tevent_req *subreq;
    136136
    137         if ((state->child->pid == 0) && (!fork_domain_child(state->child))) {
     137        if ((state->child->sock == -1) && (!fork_domain_child(state->child))) {
    138138                tevent_req_error(req, errno);
    139139                return;
     
    165165        TALLOC_FREE(subreq);
    166166        if (ret == -1) {
     167                /*
     168                 * The basic parent/child communication broke, close
     169                 * our socket
     170                 */
     171                close(state->child->sock);
     172                state->child->sock = -1;
    167173                tevent_req_error(req, err);
    168174                return;
     
    503509        }
    504510
     511        child->sock = -1;
    505512        child->domain = domain;
    506513        child->table = table;
     
    531538
    532539        DLIST_REMOVE(children, child);
    533 
    534         close(child->sock);
    535         child->sock = -1;
    536540        child->pid = 0;
    537541}
  • branches/samba-3.5.x/source3/winbindd/winbindd_pam.c

    r599 r732  
    13831383                                  &my_info3);
    13841384
    1385                 if ((NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR)
    1386                     && contact_domain->can_do_samlogon_ex) {
    1387                         DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
    1388                                   "retrying with NetSamLogon\n"));
    1389                         contact_domain->can_do_samlogon_ex = false;
     1385                if (NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR) {
     1386
    13901387                        /*
    13911388                         * It's likely that the server also does not support
     
    13931390                         */
    13941391                        domain->can_do_validation6 = false;
    1395                         retry = true;
    1396                         continue;
     1392
     1393                        if (contact_domain->can_do_samlogon_ex) {
     1394                                DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
     1395                                          "retrying with NetSamLogon\n"));
     1396                                contact_domain->can_do_samlogon_ex = false;
     1397                                retry = true;
     1398                                continue;
     1399                        }
     1400
     1401                        /* Got DCERPC_FAULT_OP_RNG_ERROR for SamLogon
     1402                         * (no Ex). This happens against old Samba
     1403                         * DCs. Drop the connection.
     1404                         */
     1405                        invalidate_cm_connection(&contact_domain->conn);
     1406                        result = NT_STATUS_LOGON_FAILURE;
     1407                        break;
    13971408                }
    13981409
     
    19972008                                  &info3);
    19982009
    1999                 if ((NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR)
    2000                     && contact_domain->can_do_samlogon_ex) {
    2001                         DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
    2002                                   "retrying with NetSamLogon\n"));
    2003                         contact_domain->can_do_samlogon_ex = false;
     2010                if (NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR) {
     2011
    20042012                        /*
    20052013                         * It's likely that the server also does not support
     
    20072015                         */
    20082016                        domain->can_do_validation6 = false;
    2009                         retry = true;
    2010                         continue;
     2017
     2018                        if (contact_domain->can_do_samlogon_ex) {
     2019                                DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
     2020                                          "retrying with NetSamLogon\n"));
     2021                                contact_domain->can_do_samlogon_ex = false;
     2022                                retry = true;
     2023                                continue;
     2024                        }
     2025
     2026                        /* Got DCERPC_FAULT_OP_RNG_ERROR for SamLogon
     2027                         * (no Ex). This happens against old Samba
     2028                         * DCs. Drop the connection.
     2029                         */
     2030                        invalidate_cm_connection(&contact_domain->conn);
     2031                        result = NT_STATUS_LOGON_FAILURE;
     2032                        break;
    20112033                }
    20122034
Note: See TracChangeset for help on using the changeset viewer.