From 458101b5776057549b35181a75b745604ae47d48 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 15 Sep 2008 14:21:28 -0700 Subject: Fix bug 5761 "open of mangled directory name results in 'is a stream name'" reported by Regan Heath . Jeremy. --- source3/smbd/open.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 8b32907a4b..71191475b3 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1852,7 +1852,8 @@ NTSTATUS open_file_ntcreate(connection_struct *conn, /* Handle strange delete on close create semantics. */ if ((create_options & FILE_DELETE_ON_CLOSE) - && (is_ntfs_stream_name(fname) + && (((conn->fs_capabilities & FILE_NAMED_STREAMS) + && is_ntfs_stream_name(fname)) || can_set_initial_delete_on_close(lck))) { status = can_set_delete_on_close(fsp, True, new_dos_attributes); @@ -2116,7 +2117,9 @@ NTSTATUS open_directory(connection_struct *conn, (unsigned int)create_disposition, (unsigned int)file_attributes)); - if (!(file_attributes & FILE_FLAG_POSIX_SEMANTICS) && is_ntfs_stream_name(fname)) { + if (!(file_attributes & FILE_FLAG_POSIX_SEMANTICS) && + (conn->fs_capabilities & FILE_NAMED_STREAMS) && + is_ntfs_stream_name(fname)) { DEBUG(2, ("open_directory: %s is a stream name!\n", fname)); return NT_STATUS_NOT_A_DIRECTORY; } @@ -2907,7 +2910,8 @@ NTSTATUS create_file(connection_struct *conn, * Check to see if this is a mac fork of some kind. */ - if (is_ntfs_stream_name(fname)) { + if ((conn->fs_capabilities & FILE_NAMED_STREAMS) && + is_ntfs_stream_name(fname)) { status = NT_STATUS_OBJECT_PATH_NOT_FOUND; goto fail; } -- cgit From 62791bbd030f7db272ca68260a4f7586de6576d0 Mon Sep 17 00:00:00 2001 From: "Gerald W. Carter" Date: Mon, 15 Sep 2008 12:38:36 -0500 Subject: idmap_ad: Fix a segfault when calling nss_get_info() with a NULL ads structure. --- source3/winbindd/idmap_ad.c | 81 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c index 9fefb1bba7..d7c87497a9 100644 --- a/source3/winbindd/idmap_ad.c +++ b/source3/winbindd/idmap_ad.c @@ -732,6 +732,16 @@ static NTSTATUS nss_ad_get_info( struct nss_domain_entry *e, uint32 *gid ) { ADS_STRUCT *ads_internal = NULL; + const char *attrs[] = {NULL, /* attr_homedir */ + NULL, /* attr_shell */ + NULL, /* attr_gecos */ + NULL, /* attr_gidnumber */ + NULL }; + char *filter = NULL; + LDAPMessage *msg_internal = NULL; + ADS_STATUS ads_status = ADS_ERROR_NT(NT_STATUS_UNSUCCESSFUL); + NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL; + char *sidstr = NULL; /* Only do query if we are online */ if (idmap_is_offline()) { @@ -743,22 +753,69 @@ static NTSTATUS nss_ad_get_info( struct nss_domain_entry *e, ads_internal = ad_idmap_cached_connection(); - if ( !ads_internal || !ad_schema ) + if ( !ads_internal || !ad_schema ) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; - - if ( !homedir || !shell || !gecos ) + } + + if (!sid || !homedir || !shell || !gecos) { return NT_STATUS_INVALID_PARAMETER; + } + + /* See if we can use the ADS connection struct swe were given */ - *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr ); - *shell = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr ); - *gecos = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr ); - - if ( gid ) { - if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) ) - *gid = (uint32)-1; + if (ads) { + *homedir = ads_pull_string( ads, ctx, msg, ad_schema->posix_homedir_attr ); + *shell = ads_pull_string( ads, ctx, msg, ad_schema->posix_shell_attr ); + *gecos = ads_pull_string( ads, ctx, msg, ad_schema->posix_gecos_attr ); + + if (gid) { + if ( !ads_pull_uint32(ads, msg, ad_schema->posix_gidnumber_attr, gid ) ) + *gid = (uint32)-1; + } + + nt_status = NT_STATUS_OK; + goto done; } - - return NT_STATUS_OK; + + /* Have to do our own query */ + + attrs[0] = ad_schema->posix_homedir_attr; + attrs[1] = ad_schema->posix_shell_attr; + attrs[2] = ad_schema->posix_gecos_attr; + attrs[3] = ad_schema->posix_gidnumber_attr; + + sidstr = sid_binstring(sid); + filter = talloc_asprintf(ctx, "(objectSid=%s)", sidstr); + SAFE_FREE(sidstr); + + if (!filter) { + nt_status = NT_STATUS_NO_MEMORY; + goto done; + } + + ads_status = ads_search_retry(ads_internal, &msg_internal, filter, attrs); + if (!ADS_ERR_OK(ads_status)) { + nt_status = ads_ntstatus(ads_status); + goto done; + } + + *homedir = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_homedir_attr); + *shell = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_shell_attr); + *gecos = ads_pull_string(ads_internal, ctx, msg_internal, ad_schema->posix_gecos_attr); + + if (gid) { + if (!ads_pull_uint32(ads_internal, msg_internal, ad_schema->posix_gidnumber_attr, gid)) + *gid = (uint32)-1; + } + + nt_status = NT_STATUS_OK; + +done: + if (msg_internal) { + ads_msgfree(ads_internal, msg_internal); + } + + return nt_status; } /************************************************************************ -- cgit From 47feb1722896bfcd20ec56df39bc0c87fd706563 Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Mon, 15 Sep 2008 15:47:43 -0700 Subject: Fix build warning on FreeBSD Fix for the following build warning: Compiling torture/cmd_vfs.c torture/cmd_vfs.c: In function `cmd_open': torture/cmd_vfs.c:275: warning: unsigned int format, different type arg (arg 3) torture/cmd_vfs.c: In function `cmd_mknod': torture/cmd_vfs.c:992: warning: unsigned int format, different type arg (arg 3) sccanf had mismatched types for mode_t between formating parameter and var args. --- source3/torture/cmd_vfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 28400887ef..dddd5bef29 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -272,7 +272,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c flagstr++; } if ((flags & O_CREAT) && argc == 4) { - if (sscanf(argv[3], "%o", &mode) == 0) { + if (sscanf(argv[3], "%ho", (unsigned short *)&mode) == 0) { printf("open: error=-1 (invalid mode!)\n"); return NT_STATUS_UNSUCCESSFUL; } @@ -989,7 +989,7 @@ static NTSTATUS cmd_mknod(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, return NT_STATUS_OK; } - if (sscanf(argv[2], "%o", &mode) == 0) { + if (sscanf(argv[2], "%ho", (unsigned short *)&mode) == 0) { printf("open: error=-1 (invalid mode!)\n"); return NT_STATUS_UNSUCCESSFUL; } -- cgit From 38fff9f9227c2c70a9d522f8355a9e1967e7cb72 Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Mon, 15 Sep 2008 15:48:55 -0700 Subject: Fixed "uninitialized variable" build warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With gcc 4.1.3 on Ubuntu 7.10 the following build warning occurs: Compiling libnet/libnet_samsync_keytab.c cc1: warnings being treated as errors libnet/libnet_samsync_keytab.c: In function ‘fetch_sam_entries_keytab’: libnet/libnet_samsync_keytab.c:102: warning: ‘entry.enctype’ is used uninitialized in this function Fixed by initializing to ENCTYPE_NULL --- source3/libnet/libnet_samsync_keytab.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/libnet/libnet_samsync_keytab.c b/source3/libnet/libnet_samsync_keytab.c index f284f08ad9..9e666ced32 100644 --- a/source3/libnet/libnet_samsync_keytab.c +++ b/source3/libnet/libnet_samsync_keytab.c @@ -93,6 +93,7 @@ static NTSTATUS fetch_sam_entry_keytab(TALLOC_CTX *mem_ctx, ctx->dns_domain_name); entry.password = data_blob_talloc(mem_ctx, nt_passwd, 16); entry.kvno = ads_get_kvno(ctx->ads, entry.name); + entry.enctype = ENCTYPE_NULL; NT_STATUS_HAVE_NO_MEMORY(entry.name); NT_STATUS_HAVE_NO_MEMORY(entry.principal); -- cgit From 61cb830f664068862613440db838c6720996dcca Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Mon, 15 Sep 2008 17:39:43 -0700 Subject: Fixed "uninitilized variable" build warning Simple fix for warning: Compiling utils/sharesec.c utils/sharesec.c: In function `change_share_sec': utils/sharesec.c:404: warning: 'sd' might be used uninitialized in this function --- source3/utils/sharesec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index 9409690c8b..46f9ecdc7d 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -401,7 +401,7 @@ static void sort_acl(SEC_ACL *the_acl) static int change_share_sec(TALLOC_CTX *mem_ctx, const char *sharename, char *the_acl, enum acl_mode mode) { - SEC_DESC *sd; + SEC_DESC *sd = NULL; SEC_DESC *old = NULL; size_t sd_size = 0; uint32 i, j; -- cgit From a59618e88b361240331ce3179b0ac97c10050c03 Mon Sep 17 00:00:00 2001 From: Timur Date: Mon, 15 Sep 2008 18:21:02 -0700 Subject: Fix cut and paste error in quota code. --- source3/smbd/quotas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/smbd/quotas.c b/source3/smbd/quotas.c index f47e89bd22..b6f748da33 100644 --- a/source3/smbd/quotas.c +++ b/source3/smbd/quotas.c @@ -544,7 +544,7 @@ static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B *bsize = gqr.getquota_rslt_u.gqr_rquota.rq_bsize; *dsize = D.dqb_bsoftlimit; - if (D.dqb_curblocks == D.dqb_curblocks == 1) + if (D.dqb_curblocks == 1) *bsize = 512; if (D.dqb_curblocks > D.dqb_bsoftlimit) { @@ -1104,7 +1104,7 @@ static bool nfs_quotas(char *nfspath, uid_t euser_id, SMB_BIG_UINT *bsize, SMB_B *bsize = gqr.getquota_rslt_u.gqr_rquota.rq_bsize; *dsize = D.dqb_bsoftlimit; - if (D.dqb_curblocks == D.dqb_curblocks == 1) + if (D.dqb_curblocks == 1) *bsize = DEV_BSIZE; if (D.dqb_curblocks > D.dqb_bsoftlimit) { -- cgit From a664cf7658b5295547983984ded6467de109f318 Mon Sep 17 00:00:00 2001 From: Timur Date: Mon, 15 Sep 2008 18:25:15 -0700 Subject: Fix display of POSIX ACLs. --- source3/client/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 1c05c4035d..7af7d30108 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -3038,7 +3038,7 @@ static int cmd_getfacl(void) break; case SMB_POSIX_ACL_GROUP: uorg = IVAL(retbuf,SMB_POSIX_ACL_HEADER_SIZE+(i*SMB_POSIX_ACL_ENTRY_SIZE)+2); - d_printf("group:%u", uorg); + d_printf("group:%u:", uorg); break; case SMB_POSIX_ACL_MASK: d_printf("mask::"); @@ -3075,7 +3075,7 @@ static int cmd_getfacl(void) break; case SMB_POSIX_ACL_GROUP: uorg = IVAL(retbuf,SMB_POSIX_ACL_HEADER_SIZE+((i+num_file_acls)*SMB_POSIX_ACL_ENTRY_SIZE)+2); - d_printf("default:group:%u", uorg); + d_printf("default:group:%u:", uorg); break; case SMB_POSIX_ACL_MASK: d_printf("default:mask::"); -- cgit From 4dfa72423ef96b411e797eb1b5b4cb3ebd8e3d32 Mon Sep 17 00:00:00 2001 From: Timur Date: Mon, 15 Sep 2008 18:45:10 -0700 Subject: Fix aio on FreeBSD. --- source3/configure.in | 15 +++++++++++++++ source3/smbd/aio.c | 17 ++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 248c39ac4c..d9766e49d0 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -876,6 +876,21 @@ if test x"$samba_cv_sig_atomic_t" = x"yes"; then AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type]) fi +AC_CACHE_CHECK([for struct sigevent type],samba_cv_struct_sigevent, [ + AC_TRY_COMPILE([ +#include +#if STDC_HEADERS +#include +#include +#endif +#include ],[struct sigevent s;], + samba_cv_struct_sigevent=yes,samba_cv_struct_sigevent=no)]) +if test x"$samba_cv_struct_sigevent" = x"yes"; then + AC_DEFINE(HAVE_STRUCT_SIGEVENT,1,[Whether we have the struct sigevent]) + AC_CHECK_MEMBERS([struct sigevent.sigev_value.sival_ptr,struct sigevent.sigev_value.sigval_ptr], , , + [#include ]) +fi + AC_CACHE_CHECK([for struct timespec type],samba_cv_struct_timespec, [ AC_TRY_COMPILE([ #include diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 74275368bd..c3fd0a2bc0 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -24,7 +24,17 @@ /* The signal we'll use to signify aio done. */ #ifndef RT_SIGNAL_AIO -#define RT_SIGNAL_AIO (SIGRTMIN+3) +#ifndef SIGRTMIN +#define SIGRTMIN NSIG +#endif +#define RT_SIGNAL_AIO (SIGRTMIN+3) +#endif + +#ifndef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR +#ifdef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR +#define sival_int sigval_int +#define sival_ptr sigval_ptr +#endif #endif /**************************************************************************** @@ -581,6 +591,11 @@ static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr) { int err; + if(!aio_ex) { + DEBUG(3, ("handle_aio_completed: Non-existing aio_ex passed\n")); + return false; + } + /* Ensure the operation has really completed. */ if (SMB_VFS_AIO_ERROR(aio_ex->fsp, &aio_ex->acb) == EINPROGRESS) { DEBUG(10,( "handle_aio_completed: operation mid %u still in " -- cgit