[SCM] Samba Shared Repository - branch master updated

David Disseldorp ddiss at samba.org
Tue Mar 5 17:17:02 MST 2013


The branch, master has been updated
       via  90cbfc9 Make sure to set umask() before calling mkstemp().
       via  7a50f08 s4-libregistry: Improve NULL handling of name.
       via  1742458 dsdb: Check for pointers before we deference them.
       via  ceb1d8b gensec: recv_handler can't be NULL at that point.
       via  cab969d s4-libregistry: Fix path check and improve while loops.
       via  2aca90b s4-libregistry: Make sure we don't dereference a NULL pointer.
       via  1e4f4f6 s4-client: Make sure entry is a valid string.
       via  69f22e1 winbind: Fix no memory check in _wbint_PingDc().
       via  157943f krb5_wrap: Make sure we don't dereference a NULL pointer.
       via  f06a035 s3-daemons: Set the comment field of the daemons.
       via  f9fb3fa lib: Add prctl_set_comment to utils.
       via  def575b waf: Correctly check for prctl in just one place.
       via  3c134bc winbind: Fix samba3.winbind.struct test.
       via  659dd65 winbind: Correctly use names in the domain struct.
       via  14bae61 winbind: Use talloc for allocating domain, dns, forest and dc name.
      from  e8e3a68 Fix the build: net_serverid.c has 3 wrong format strings for 64bit vars

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 90cbfc96d118d6b55c47392d8ae421434dea8225
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 17:34:21 2013 +0100

    Make sure to set umask() before calling mkstemp().
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): David Disseldorp <ddiss at samba.org>
    Autobuild-Date(master): Wed Mar  6 01:16:34 CET 2013 on sn-devel-104

commit 7a50f089e0ae70ec7652575e11fbf87a9f6a86e7
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 17:16:45 2013 +0100

    s4-libregistry: Improve NULL handling of name.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 17424588c5d7b7dd1cda5eb6ca0d7d13524b963a
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 15:48:20 2013 +0100

    dsdb: Check for pointers before we deference them.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit ceb1d8b84a6bd7084447e4cc75bd6821d6fdbe34
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 15:41:23 2013 +0100

    gensec: recv_handler can't be NULL at that point.
    
    We probably want to segfault here if it is NULL.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit cab969d5ec67b1b3afbd4be2ff3a0d3cec45fd45
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 15:13:19 2013 +0100

    s4-libregistry: Fix path check and improve while loops.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 2aca90b9a00e0727d640c235ef71a9a8b0c5fdca
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 15:01:18 2013 +0100

    s4-libregistry: Make sure we don't dereference a NULL pointer.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 1e4f4f6d921961c02398e51b97c6ff0c0bdf561d
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 14:58:45 2013 +0100

    s4-client: Make sure entry is a valid string.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 69f22e17d7cfe305de757f613c18cb0a2c303756
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 14:55:48 2013 +0100

    winbind: Fix no memory check in _wbint_PingDc().
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 157943fdfb47e6b72cb5596d6685152d0de328a7
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 14:52:23 2013 +0100

    krb5_wrap: Make sure we don't dereference a NULL pointer.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit f06a0352e551ea125675659923c909d6d4c473fd
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 10:41:18 2013 +0100

    s3-daemons: Set the comment field of the daemons.
    
    PR_SET_NAME sets the comm field of a process. This way we can give
    processes a name and they are easier to identify.
    
    $ ps afx -o pid,comm
    29447 smbd
    29452  \_ epmd
    29453  \_ lsasd-master
    29455  |   \_ lsasd-child
    29457  |   \_ lsasd-child
    29459  |   \_ lsasd-child
    29461  |   \_ lsasd-child
    29463  |   \_ lsasd-child
    29454  \_ spoolssd-master
    29456      \_ lpqd
    29458      \_ spoolssd-child
    29460      \_ spoolssd-child
    29462      \_ spoolssd-child
    29465      \_ spoolssd-child
    29466      \_ spoolssd-child
    29467      \_ spoolssd-child
    29468      \_ spoolssd-child
    29469      \_ spoolssd-child
    29470      \_ spoolssd-child
    29471      \_ spoolssd-child
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit f9fb3faaef4c15b7c4c3748b0e93fa3061b573c3
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Mar 5 15:54:44 2013 +0100

    lib: Add prctl_set_comment to utils.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit def575bc29ee399fc93320b0f3716bc15740863d
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 10:02:35 2013 +0100

    waf: Correctly check for prctl in just one place.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 3c134bcf86a156b8b0292e6a8108050273038b29
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Feb 21 12:14:55 2013 +0100

    winbind: Fix samba3.winbind.struct test.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 659dd65f8f5c352a4cd17e072929a8cc0b6e4d34
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 25 09:31:12 2013 +0100

    winbind: Correctly use names in the domain struct.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

commit 14bae61ba36814ea5eca7c51cf1cc039e9e6803f
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 18 16:36:22 2013 +0100

    winbind: Use talloc for allocating domain, dns, forest and dc name.
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/krb5_wrap/krb5_samba.c                         |    8 +-
 lib/replace/wscript                                |   15 ++-
 lib/util/util.c                                    |    3 +
 .../lib/version_test.c => lib/util/util_process.c  |   18 ++-
 lib/{smbconf/smbconf_txt.h => util/util_process.h} |   26 ++--
 lib/util/wscript_build                             |    2 +-
 libgpo/gpo_ini.c                                   |    3 +
 source3/Makefile.in                                |    2 +-
 source3/client/client.c                            |    3 +
 source3/lib/smbrun.c                               |    4 +
 source3/libads/kerberos.c                          |    3 +
 source3/libnet/libnet_samsync_ldif.c               |   30 ++++-
 source3/printing/printing.c                        |    3 +
 source3/printing/printspoolss.c                    |    4 +
 source3/printing/queue_process.c                   |    3 +
 source3/printing/spoolssd.c                        |    6 +
 source3/rpc_server/epmd.c                          |    4 +
 source3/rpc_server/lsasd.c                         |    6 +
 source3/smbd/message.c                             |    4 +
 source3/utils/interact.c                           |    7 +-
 source3/utils/net_usershare.c                      |    3 +
 source3/winbindd/winbindd.h                        |    8 +-
 source3/winbindd/winbindd_ads.c                    |    7 +-
 source3/winbindd/winbindd_cache.c                  |   30 ++++-
 source3/winbindd/winbindd_cm.c                     |  130 ++++++++++++++------
 source3/winbindd/winbindd_dual.c                   |   24 +++-
 source3/winbindd/winbindd_dual_srv.c               |    2 +-
 source3/winbindd/winbindd_misc.c                   |    6 +-
 source3/winbindd/winbindd_pam.c                    |   22 +++-
 source3/winbindd/winbindd_util.c                   |   38 +++---
 source3/wscript                                    |   10 +--
 source4/auth/gensec/socket.c                       |    2 +-
 source4/client/client.c                            |   13 ++-
 source4/dsdb/common/dsdb_dn.c                      |   14 +-
 source4/lib/registry/local.c                       |   12 +-
 source4/lib/registry/regf.c                        |   11 +-
 36 files changed, 356 insertions(+), 130 deletions(-)
 copy source3/lib/version_test.c => lib/util/util_process.c (68%)
 copy lib/{smbconf/smbconf_txt.h => util/util_process.h} (62%)


Changeset truncated at 500 lines:

diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c
index ffb3f8d..3a2401a 100644
--- a/lib/krb5_wrap/krb5_samba.c
+++ b/lib/krb5_wrap/krb5_samba.c
@@ -21,6 +21,7 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
 #include "krb5_samba.h"
 #include "lib/util/asn1.h"
 
@@ -1400,7 +1401,9 @@ krb5_error_code smb_krb5_get_credentials(krb5_context context,
 	krb5_error_code ret;
 	krb5_creds *creds = NULL;
 
-	*out_creds = NULL;
+	if (out_creds != NULL) {
+		*out_creds = NULL;
+	}
 
 	if (impersonate_princ) {
 #ifdef HAVE_KRB5_GET_CREDS_OPT_SET_IMPERSONATE /* Heimdal */
@@ -1481,6 +1484,7 @@ krb5_error_code kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc,
 {
 	krb5_error_code code = 0;
 	krb5_creds my_creds;
+	mode_t mask;
 
 #if defined(HAVE_KRB5_GET_INIT_CREDS_KEYBLOCK)
 	code = krb5_get_init_creds_keyblock(ctx, &my_creds, principal,
@@ -1498,7 +1502,9 @@ krb5_error_code kerberos_kinit_keyblock_cc(krb5_context ctx, krb5_ccache cc,
 	*(KRB5_KT_KEY(&entry)) = *keyblock;
 
 	memcpy(tmp_name, SMB_CREDS_KEYTAB, sizeof(SMB_CREDS_KEYTAB));
+	mask = umask(S_IRWXO | S_IRWXG);
 	mktemp(tmp_name);
+	umask(mask);
 	if (tmp_name[0] == 0) {
 		return KRB5_KT_BADNAME;
 	}
diff --git a/lib/replace/wscript b/lib/replace/wscript
index 47735be..36a9f6a 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -94,7 +94,7 @@ struct foo bar = { .y = 'X', .x = 1 };
     conf.CHECK_HEADERS('security/pam_appl.h zlib.h asm/unistd.h')
     conf.CHECK_HEADERS('aio.h sys/unistd.h rpc/rpc.h rpc/nettype.h alloca.h float.h')
 
-    conf.CHECK_HEADERS('rpcsvc/nis.h rpcsvc/ypclnt.h sys/prctl.h sys/sysctl.h')
+    conf.CHECK_HEADERS('rpcsvc/nis.h rpcsvc/ypclnt.h sys/sysctl.h')
     conf.CHECK_HEADERS('sys/fileio.h sys/filesys.h sys/dustat.h sys/sysmacros.h')
     conf.CHECK_HEADERS('xfs/libxfs.h netgroup.h')
 
@@ -106,6 +106,18 @@ struct foo bar = { .y = 'X', .x = 1 };
     conf.CHECK_HEADERS('utmp.h utmpx.h lastlog.h malloc.h')
     conf.CHECK_HEADERS('syscall.h sys/syscall.h inttypes.h')
 
+    # Check for process set name support
+    conf.CHECK_CODE('''
+                    #include <sys/prctl.h>
+                    int main(void) {
+                        prctl(0);
+                        return 0;
+                    }
+                    ''',
+                    'HAVE_PRCTL',
+                    headers='sys/prctl.h',
+                    msg='Checking for prctl syscall')
+
     conf.CHECK_CODE('''
                     #include <unistd.h>
                     #ifdef HAVE_FCNTL_H
@@ -225,6 +237,7 @@ struct foo bar = { .y = 'X', .x = 1 };
     conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf')
     conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
     conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memalign posix_memalign')
+    conf.CHECK_FUNCS('prctl')
 
     # libbsd on some platforms provides strlcpy and strlcat
     if not conf.CHECK_FUNCS('strlcpy strlcat'):
diff --git a/lib/util/util.c b/lib/util/util.c
index d49e20e..464fc62 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -63,6 +63,7 @@ int create_unlink_tmp(const char *dir)
 {
 	char *fname;
 	int fd;
+	mode_t mask;
 
 	if (!dir) {
 		dir = tmpdir();
@@ -73,7 +74,9 @@ int create_unlink_tmp(const char *dir)
 		errno = ENOMEM;
 		return -1;
 	}
+	mask = umask(S_IRWXO | S_IRWXG);
 	fd = mkstemp(fname);
+	umask(mask);
 	if (fd == -1) {
 		TALLOC_FREE(fname);
 		return -1;
diff --git a/source3/lib/version_test.c b/lib/util/util_process.c
similarity index 68%
copy from source3/lib/version_test.c
copy to lib/util/util_process.c
index 880cfeb..6036e27 100644
--- a/source3/lib/version_test.c
+++ b/lib/util/util_process.c
@@ -1,7 +1,9 @@
 /*
  *  Unix SMB/CIFS implementation.
- *  version_test - test program for samba_version_strion()
- *  Copyright (C) Michael Adam 2009
+ *
+ *  Process utils.
+ *
+ *  Copyright (c) 2013      Andreas Schneider <asn at samba.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -17,10 +19,16 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "includes.h"
+#include "util_process.h"
+
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
 
-int main(void)
+int prctl_set_comment(const char *comment)
 {
-	printf("%s\n", samba_version_string());
+#if defined(HAVE_PRCTL) && defined(PR_SET_NAME)
+	return prctl(PR_SET_NAME, (unsigned long) comment, 0, 0, 0);
+#endif
 	return 0;
 }
diff --git a/lib/smbconf/smbconf_txt.h b/lib/util/util_process.h
similarity index 62%
copy from lib/smbconf/smbconf_txt.h
copy to lib/util/util_process.h
index 72d6207..6e1ef07 100644
--- a/lib/smbconf/smbconf_txt.h
+++ b/lib/util/util_process.h
@@ -1,7 +1,9 @@
 /*
  *  Unix SMB/CIFS implementation.
- *  libsmbconf - Samba configuration library
- *  Copyright (C) Michael Adam 2009
+ *
+ *  Process utils.
+ *
+ *  Copyright (c) 2013      Andreas Schneider <asn at samba.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -17,17 +19,17 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __LIBSMBCONF_TXT_H__
-#define __LIBSMBCONF_TXT_H__
-
-struct smbconf_ctx;
+#ifndef _SAMBA_UTIL_PROCESS_H
+#define _SAMBA_UTIL_PROCESS_H
 
 /**
- * initialization functions for the text/file backend modules
+ * @brief Set the process comment name.
+ *
+ * @param[in]  comment  The comment to set which shouldn't be longer than 16
+ *                      16 characters (including \0).
+ *
+ * @return              -1 on error, 0 on success.
  */
+int prctl_set_comment(const char *comment);
 
-sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx,
-			struct smbconf_ctx **conf_ctx,
-			const char *path);
-
-#endif /*  _LIBSMBCONF_TXT_H_  */
+#endif
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index ac270ee..39a1613 100755
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -8,7 +8,7 @@ bld.SAMBA_LIBRARY('samba-util',
                     util_strlist.c util_paths.c idtree.c debug.c fault.c base64.c
                     util_str.c util_str_common.c substitute.c ms_fnmatch.c
                     server_id.c dprintf.c parmlist.c bitmap.c pidfile.c
-                    tevent_debug.c''',
+                    tevent_debug.c util_process.c''',
                   deps='DYNCONFIG',
                   public_deps='talloc tevent execinfo uid_wrapper pthread LIBCRYPTO charset util_setid',
                   public_headers='debug.h attr.h byteorder.h data_blob.h memory.h safe_string.h time.h talloc_stack.h xfile.h dlinklist.h samba_util.h string_wrappers.h',
diff --git a/libgpo/gpo_ini.c b/libgpo/gpo_ini.c
index 4941624..a2cb106 100644
--- a/libgpo/gpo_ini.c
+++ b/libgpo/gpo_ini.c
@@ -63,6 +63,7 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
 	NTSTATUS status;
 	size_t n = 0;
 	size_t converted_size;
+	mode_t mask;
 
 	if (!filename_out) {
 		return NT_STATUS_INVALID_PARAMETER;
@@ -81,7 +82,9 @@ static NTSTATUS convert_file_from_ucs2(TALLOC_CTX *mem_ctx,
 		goto out;
 	}
 
+	mask = umask(S_IRWXO | S_IRWXG);
 	tmp_fd = mkstemp(tmp_name);
+	umask(mask);
 	if (tmp_fd == -1) {
 		status = NT_STATUS_ACCESS_DENIED;
 		goto out;
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 90f12b7..4b6918a 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -430,7 +430,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
 		   ../lib/util/genrand.o ../lib/util/util_net.o \
 		   ../lib/util/become_daemon.o ../lib/util/system.o \
 		   ../lib/util/tevent_unix.o ../lib/util/tevent_ntstatus.o \
-		   ../lib/util/tevent_werror.o \
+		   ../lib/util/tevent_werror.o ../lib/util/util_process.o\
 		   lib/tevent_barrier.o \
 		   ../lib/util/smb_threads.o ../lib/util/util_id.o \
 		   ../lib/util/blocking.o ../lib/util/rfc1738.o \
diff --git a/source3/client/client.c b/source3/client/client.c
index 8038021..e21d867 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -1361,6 +1361,7 @@ static int cmd_more(void)
 	const char *pager;
 	int fd;
 	int rc = 0;
+	mode_t mask;
 
 	rname = talloc_strdup(ctx, client_get_cur_dir());
 	if (!rname) {
@@ -1371,7 +1372,9 @@ static int cmd_more(void)
 	if (!lname) {
 		return 1;
 	}
+	mask = umask(S_IRWXO | S_IRWXG);
 	fd = mkstemp(lname);
+	umask(mask);
 	if (fd == -1) {
 		d_printf("failed to create temporary file for more\n");
 		return 1;
diff --git a/source3/lib/smbrun.c b/source3/lib/smbrun.c
index 0ecdc0d..15a0c88 100644
--- a/source3/lib/smbrun.c
+++ b/source3/lib/smbrun.c
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
 
 /* need to move this from here!! need some sleep ... */
 struct current_user current_user;
@@ -31,6 +32,7 @@ static int setup_out_fd(void)
 	int fd;
 	TALLOC_CTX *ctx = talloc_stackframe();
 	char *path = NULL;
+	mode_t mask;
 
 	path = talloc_asprintf(ctx,
 				"%s/smb.XXXXXX",
@@ -42,7 +44,9 @@ static int setup_out_fd(void)
 	}
 
 	/* now create the file */
+	mask = umask(S_IRWXO | S_IRWXG);
 	fd = mkstemp(path);
+	umask(mask);
 
 	if (fd == -1) {
 		DEBUG(0,("setup_out_fd: Failed to create file %s. (%s)\n",
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index 50a409c..96d194d 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -833,6 +833,7 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
 	char *realm_upper = NULL;
 	bool result = false;
 	char *aes_enctypes = NULL;
+	mode_t mask;
 
 	if (!lp_create_krb5_conf()) {
 		return false;
@@ -906,7 +907,9 @@ bool create_local_private_krb5_conf_for_domain(const char *realm,
 
 	flen = strlen(file_contents);
 
+	mask = umask(S_IRWXO | S_IRWXG);
 	fd = mkstemp(tmpname);
+	umask(mask);
 	if (fd == -1) {
 		DEBUG(0,("create_local_private_krb5_conf_for_domain: smb_mkstemp failed,"
 			" for file %s. Errno %s\n",
diff --git a/source3/libnet/libnet_samsync_ldif.c b/source3/libnet/libnet_samsync_ldif.c
index c492b9f..2ea9c82 100644
--- a/source3/libnet/libnet_samsync_ldif.c
+++ b/source3/libnet/libnet_samsync_ldif.c
@@ -24,6 +24,7 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
 #include "libnet/libnet_samsync.h"
 #include "transfer_file.h"
 #include "passdb.h"
@@ -929,6 +930,8 @@ static NTSTATUS ldif_init_context(TALLOC_CTX *mem_ctx,
 	const char *add_template = "/tmp/add.ldif.XXXXXX";
 	const char *mod_template = "/tmp/mod.ldif.XXXXXX";
 	const char *builtin_sid = "S-1-5-32";
+	mode_t mask;
+	int fd;
 
 	r = talloc_zero(mem_ctx, struct samsync_ldif_context);
 	NT_STATUS_HAVE_NO_MEMORY(r);
@@ -980,14 +983,37 @@ static NTSTATUS ldif_init_context(TALLOC_CTX *mem_ctx,
 		goto done;
 	}
 
+	mask = umask(S_IRWXO | S_IRWXG);
+	fd = mkstemp(r->add_name);
+	umask(mask);
+	if (fd < 0) {
+		DEBUG(1, ("Could not create %s\n", r->add_name));
+		status = NT_STATUS_UNSUCCESSFUL;
+		goto done;
+	}
+
 	/* Open the add and mod ldif files */
-	if (!(r->add_file = fdopen(mkstemp(r->add_name),"w"))) {
+	r->add_file = fdopen(fd, "w");
+	if (r->add_file == NULL) {
 		DEBUG(1, ("Could not open %s\n", r->add_name));
+		close(fd);
 		status = NT_STATUS_UNSUCCESSFUL;
 		goto done;
 	}
-	if (!(r->mod_file = fdopen(mkstemp(r->module_name),"w"))) {
+
+	mask = umask(S_IRWXO | S_IRWXG);
+	fd = mkstemp(r->module_name);
+	umask(mask);
+	if (fd < 0) {
+		DEBUG(1, ("Could not create %s\n", r->module_name));
+		status = NT_STATUS_UNSUCCESSFUL;
+		goto done;
+	}
+
+	r->mod_file = fdopen(fd, "w");
+	if (r->mod_file == NULL) {
 		DEBUG(1, ("Could not open %s\n", r->module_name));
+		close(fd);
 		status = NT_STATUS_UNSUCCESSFUL;
 		goto done;
 	}
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index c394118..43f75e5 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -2709,6 +2709,7 @@ static WERROR print_job_spool_file(int snum, uint32_t jobid,
 	SMB_STRUCT_STAT st;
 	const char *path;
 	int len;
+	mode_t mask;
 
 	/* if this file is within the printer path, it means that smbd
 	 * is spooling it and will pass us control when it is finished.
@@ -2746,7 +2747,9 @@ static WERROR print_job_spool_file(int snum, uint32_t jobid,
 	slprintf(pjob->filename, sizeof(pjob->filename)-1,
 		 "%s/%sXXXXXX", lp_pathname(talloc_tos(), snum),
 		 PRINT_SPOOL_PREFIX);
+	mask = umask(S_IRWXO | S_IRWXG);
 	pjob->fd = mkstemp(pjob->filename);
+	umask(mask);
 
 	if (pjob->fd == -1) {
 		werr = map_werror_from_unix(errno);
diff --git a/source3/printing/printspoolss.c b/source3/printing/printspoolss.c
index acf4c0d..5fab7d5 100644
--- a/source3/printing/printspoolss.c
+++ b/source3/printing/printspoolss.c
@@ -18,6 +18,7 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
 #include "printing.h"
 #include "rpc_client/rpc_client.h"
 #include "../librpc/gen_ndr/ndr_spoolss_c.h"
@@ -68,6 +69,7 @@ NTSTATUS print_spool_open(files_struct *fsp,
 	struct spoolss_DocumentInfo1 *info1;
 	int fd = -1;
 	WERROR werr;
+	mode_t mask;
 
 	tmp_ctx = talloc_new(fsp);
 	if (!tmp_ctx) {
@@ -127,7 +129,9 @@ NTSTATUS print_spool_open(files_struct *fsp,
 		goto done;
 	}
 	errno = 0;
+	mask = umask(S_IRWXO | S_IRWXG);
 	fd = mkstemp(pf->filename);
+	umask(mask);
 	if (fd == -1) {
 		if (errno == EACCES) {
 			/* Common setup error, force a report. */
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index 1ca186e..bc6c33f 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -23,6 +23,7 @@
 #include "includes.h"
 #include "smbd/globals.h"
 #include "include/messages.h"
+#include "lib/util/util_process.h"
 #include "printing.h"
 #include "printing/pcap.h"
 #include "printing/queue_process.h"
@@ -286,6 +287,8 @@ pid_t start_background_queue(struct tevent_context *ev,
 			smb_panic("reinit_after_fork() failed");
 		}
 
+		prctl_set_comment("lpqd");
+
 		bq_reopen_logs(logfile);
 		bq_setup_sig_term_handler();
 		bq_setup_sig_hup_handler(ev, msg_ctx);
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index db303a1..464d12b 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -20,6 +20,8 @@
 #include "serverid.h"
 #include "smbd/smbd.h"
 
+#include "lib/util/util_process.h"
+
 #include "messages.h"
 #include "include/printing.h"
 #include "printing/nt_printing_migrate_internal.h"
@@ -293,6 +295,8 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
 		smb_panic("reinit_after_fork() failed");
 	}
 
+	prctl_set_comment("spoolssd-child");
+
 	spoolss_child_id = child_id;
 	spoolss_reopen_logs(child_id);
 
@@ -670,6 +674,8 @@ pid_t start_spoolssd(struct tevent_context *ev_ctx,
 		smb_panic("reinit_after_fork() failed");
 	}
 
+	prctl_set_comment("spoolssd-master");
+
 	/* save the parent process id so the children can use it later */
 	parent_id = messaging_server_id(msg_ctx);
 
diff --git a/source3/rpc_server/epmd.c b/source3/rpc_server/epmd.c
index 0e7b430..8d77c4a 100644
--- a/source3/rpc_server/epmd.c
+++ b/source3/rpc_server/epmd.c
@@ -25,6 +25,8 @@
 #include "ntdomain.h"
 #include "messages.h"
 
+#include "lib/util/util_process.h"
+
 #include "librpc/rpc/dcerpc_ep.h"
 #include "../librpc/gen_ndr/srv_epmapper.h"
 #include "rpc_server/rpc_server.h"
@@ -168,6 +170,8 @@ void start_epmd(struct tevent_context *ev_ctx,
 		smb_panic("reinit_after_fork() failed");
 	}
 
+	prctl_set_comment("epmd");
+
 	epmd_reopen_logs();
 
 	epmd_setup_sig_term_handler(ev_ctx);
diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c
index 72ad785..9815ad9 100644


-- 
Samba Shared Repository


More information about the samba-cvs mailing list