summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-07-29 03:08:05 +0000
committerAndrew Tridgell <tridge@samba.org>1998-07-29 03:08:05 +0000
commit64578c0589a3a741f81fb55c16eeb882128da00b (patch)
tree8b650156e44e4d39af8625185d857a88789b8074 /source3/passdb
parentc48b3fce6be6d5d952cbcda0ddae223dda5a576f (diff)
downloadsamba-64578c0589a3a741f81fb55c16eeb882128da00b.tar.gz
samba-64578c0589a3a741f81fb55c16eeb882128da00b.tar.bz2
samba-64578c0589a3a741f81fb55c16eeb882128da00b.zip
merge from the autoconf2 branch to the main branch
(This used to be commit 3bda7ac417107a7b01d91805ca71c4330657ed21)
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/ldap.c2
-rw-r--r--source3/passdb/nispass.c14
-rw-r--r--source3/passdb/passdb.c306
-rw-r--r--source3/passdb/smbpass.c2
-rw-r--r--source3/passdb/smbpassfile.c4
5 files changed, 166 insertions, 162 deletions
diff --git a/source3/passdb/ldap.c b/source3/passdb/ldap.c
index b644e8bb69..2e98cad4be 100644
--- a/source3/passdb/ldap.c
+++ b/source3/passdb/ldap.c
@@ -20,7 +20,7 @@
*/
-#ifdef USE_LDAP_DB
+#ifdef WITH_LDAP
#include "includes.h"
diff --git a/source3/passdb/nispass.c b/source3/passdb/nispass.c
index 84eae0a40f..b43a52e48a 100644
--- a/source3/passdb/nispass.c
+++ b/source3/passdb/nispass.c
@@ -19,7 +19,7 @@
* Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifdef USE_NISPLUS_DB
+#ifdef WITH_NISPLUS
#include "includes.h"
#include <rpcsvc/nis.h>
@@ -166,7 +166,7 @@ static nis_result *nisp_get_nis_list(char *nis_name)
result = nis_list(nis_name, FOLLOW_PATH|EXPAND_NAME|HARD_LOOKUP,NULL,NULL);
alarm(0);
- signal(SIGALRM, SIGNAL_CAST SIG_DFL);
+ CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
if (gotalarm)
{
@@ -531,13 +531,13 @@ static struct sam_passwd *getnisp21pwnam(char *name)
/* Search the table. */
gotalarm = 0;
- signal(SIGALRM, SIGNAL_CAST gotalarm_sig);
+ CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
alarm(5);
result = nis_list(nisname, FOLLOW_PATH | EXPAND_NAME | HARD_LOOKUP, NULL, NULL);
alarm(0);
- signal(SIGALRM, SIGNAL_CAST SIG_DFL);
+ CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
if (gotalarm)
{
@@ -576,13 +576,13 @@ static struct sam_passwd *getnisp21pwrid(uint32 rid)
/* Search the table. */
gotalarm = 0;
- signal(SIGALRM, SIGNAL_CAST gotalarm_sig);
+ CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
alarm(5);
result = nis_list(nisname, FOLLOW_PATH | EXPAND_NAME | HARD_LOOKUP, NULL, NULL);
alarm(0);
- signal(SIGALRM, SIGNAL_CAST SIG_DFL);
+ CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
if (gotalarm)
{
@@ -674,7 +674,7 @@ struct passdb_ops *nisplus_initialize_password_db(void)
#else
void nisplus_dummy_function(void) { } /* stop some compilers complaining */
-#endif /* USE_NISPLUS_DB */
+#endif /* WITH_NISPLUS */
/* useful code i can't bring myself to delete */
#if 0
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index cc4a8e5c55..0ca71dda94 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -88,17 +88,13 @@ BOOL initialize_password_db(void)
return True;
}
-#ifdef USE_NISPLUS_DB
+#ifdef WITH_NISPLUS
pdb_ops = nisplus_initialize_password_db();
-#endif /* USE_NISPLUS_DB */
-
-#ifdef USE_LDAP_DB
+#elif defined(WITH_LDAP)
pdb_ops = ldap_initialize_password_db();
-#endif /* USE_LDAP_DB */
-
-#ifdef USE_SMBPASS_DB
+#else
pdb_ops = file_initialize_password_db();
-#endif /* USE_SMBPASS_DB */
+#endif
return (pdb_ops != NULL);
}
@@ -899,159 +895,167 @@ static BOOL read_sid_from_file(int fd, char *sid_file)
Generate the global machine sid. Look for the MACHINE.SID file first, if
not found then look in smb.conf and use it to create the MACHINE.SID file.
****************************************************************************/
-
BOOL pdb_generate_machine_sid(void)
{
- int fd;
- char *p;
- pstring sid_file;
- fstring sid_string;
- struct stat st;
- uchar raw_sid_data[12];
-
- pstrcpy(sid_file, lp_smb_passwd_file());
- p = strrchr(sid_file, '/');
- if(p != NULL)
- *++p = '\0';
-
- pstrcat(sid_file, "MACHINE.SID");
-
- if((fd = open( sid_file, O_RDWR | O_CREAT, 0644)) < 0 ) {
- DEBUG(0,("generate_machine_sid: unable to open or create file %s. Error was %s\n",
- sid_file, strerror(errno) ));
- return False;
- }
-
- /*
- * Check if the file contains data.
- */
+ int fd;
+ char *p;
+ pstring sid_file;
+ fstring sid_string;
+ struct stat st;
+ uchar raw_sid_data[12];
+
+ pstrcpy(sid_file, lp_smb_passwd_file());
+ p = strrchr(sid_file, '/');
+ if(p != NULL) {
+ *++p = '\0';
+ }
+
+ if (!directory_exist(sid_file, NULL)) {
+ if (sys_mkdir(sid_file, 0700) != 0) {
+ DEBUG(0,("generate_machine_sid: can't create private directory %s : %s\n",
+ sid_file, strerror(errno)));
+ return False;
+ }
+ }
+
+ pstrcat(sid_file, "MACHINE.SID");
- if(fstat( fd, &st) < 0) {
- DEBUG(0,("generate_machine_sid: unable to stat file %s. Error was %s\n",
- sid_file, strerror(errno) ));
- close(fd);
- return False;
- }
+ if((fd = open(sid_file, O_RDWR | O_CREAT, 0644)) == -1) {
+ DEBUG(0,("generate_machine_sid: unable to open or create file %s. Error was %s\n",
+ sid_file, strerror(errno) ));
+ return False;
+ }
- if(st.st_size > 0) {
- /*
- * We have a valid SID - read it.
- */
- if(!read_sid_from_file( fd, sid_file)) {
- DEBUG(0,("generate_machine_sid: unable to read file %s. Error was %s\n",
- sid_file, strerror(errno) ));
- close(fd);
- return False;
- }
- close(fd);
- return True;
- }
+ /*
+ * Check if the file contains data.
+ */
+
+ if(fstat( fd, &st) < 0) {
+ DEBUG(0,("generate_machine_sid: unable to stat file %s. Error was %s\n",
+ sid_file, strerror(errno) ));
+ close(fd);
+ return False;
+ }
- /*
- * The file contains no data - we may need to generate our
- * own sid. Try the lp_domain_sid() first.
- */
-
- if(*lp_domain_sid())
- fstrcpy( sid_string, lp_domain_sid());
- else {
- /*
- * Generate the new sid data & turn it into a string.
- */
- int i;
- generate_random_buffer( raw_sid_data, 12, True);
-
- fstrcpy( sid_string, "S-1-5-21");
- for( i = 0; i < 3; i++) {
- fstring tmp_string;
- slprintf( tmp_string, sizeof(tmp_string) - 1, "-%u", IVAL(raw_sid_data, i*4));
- fstrcat( sid_string, tmp_string);
- }
- }
+ if(st.st_size > 0) {
+ /*
+ * We have a valid SID - read it.
+ */
+ if(!read_sid_from_file( fd, sid_file)) {
+ DEBUG(0,("generate_machine_sid: unable to read file %s. Error was %s\n",
+ sid_file, strerror(errno) ));
+ close(fd);
+ return False;
+ }
+ close(fd);
+ return True;
+ }
- fstrcat(sid_string, "\n");
-
- /*
- * Ensure our new SID is valid.
- */
-
- if(!string_to_sid( &global_machine_sid, sid_string)) {
- DEBUG(0,("generate_machine_sid: unable to generate machine SID.\n"));
- return False;
- }
+ /*
+ * The file contains no data - we may need to generate our
+ * own sid. Try the lp_domain_sid() first.
+ */
+
+ if(*lp_domain_sid())
+ fstrcpy( sid_string, lp_domain_sid());
+ else {
+ /*
+ * Generate the new sid data & turn it into a string.
+ */
+ int i;
+ generate_random_buffer( raw_sid_data, 12, True);
+
+ fstrcpy( sid_string, "S-1-5-21");
+ for( i = 0; i < 3; i++) {
+ fstring tmp_string;
+ slprintf( tmp_string, sizeof(tmp_string) - 1, "-%u", IVAL(raw_sid_data, i*4));
+ fstrcat( sid_string, tmp_string);
+ }
+ }
+
+ fstrcat(sid_string, "\n");
+
+ /*
+ * Ensure our new SID is valid.
+ */
+
+ if(!string_to_sid( &global_machine_sid, sid_string)) {
+ DEBUG(0,("generate_machine_sid: unable to generate machine SID.\n"));
+ return False;
+ }
- /*
- * Do an exclusive blocking lock on the file.
- */
-
- if(!do_file_lock( fd, 60, F_WRLCK)) {
- DEBUG(0,("generate_machine_sid: unable to lock file %s. Error was %s\n",
- sid_file, strerror(errno) ));
- close(fd);
- return False;
- }
+ /*
+ * Do an exclusive blocking lock on the file.
+ */
+
+ if(!do_file_lock( fd, 60, F_WRLCK)) {
+ DEBUG(0,("generate_machine_sid: unable to lock file %s. Error was %s\n",
+ sid_file, strerror(errno) ));
+ close(fd);
+ return False;
+ }
- /*
- * At this point we have a blocking lock on the SID
- * file - check if in the meantime someone else wrote
- * SID data into the file. If so - they were here first,
- * use their data.
- */
-
- if(fstat( fd, &st) < 0) {
- DEBUG(0,("generate_machine_sid: unable to stat file %s. Error was %s\n",
- sid_file, strerror(errno) ));
- close(fd);
- return False;
- }
+ /*
+ * At this point we have a blocking lock on the SID
+ * file - check if in the meantime someone else wrote
+ * SID data into the file. If so - they were here first,
+ * use their data.
+ */
+
+ if(fstat( fd, &st) < 0) {
+ DEBUG(0,("generate_machine_sid: unable to stat file %s. Error was %s\n",
+ sid_file, strerror(errno) ));
+ close(fd);
+ return False;
+ }
- if(st.st_size > 0) {
- /*
- * Unlock as soon as possible to reduce
- * contention on the exclusive lock.
- */
- do_file_lock( fd, 60, F_UNLCK);
-
- /*
- * We have a valid SID - read it.
- */
-
- if(!read_sid_from_file( fd, sid_file)) {
- DEBUG(0,("generate_machine_sid: unable to read file %s. Error was %s\n",
- sid_file, strerror(errno) ));
- close(fd);
- return False;
- }
- close(fd);
- return True;
- }
-
- /*
- * The file is still empty and we have an exlusive lock on it.
- * Write out out SID data into the file.
- */
-
- if(fchmod(fd, 0644) < 0) {
- DEBUG(0,("generate_machine_sid: unable to set correct permissions on file %s. \
+ if(st.st_size > 0) {
+ /*
+ * Unlock as soon as possible to reduce
+ * contention on the exclusive lock.
+ */
+ do_file_lock( fd, 60, F_UNLCK);
+
+ /*
+ * We have a valid SID - read it.
+ */
+
+ if(!read_sid_from_file( fd, sid_file)) {
+ DEBUG(0,("generate_machine_sid: unable to read file %s. Error was %s\n",
+ sid_file, strerror(errno) ));
+ close(fd);
+ return False;
+ }
+ close(fd);
+ return True;
+ }
+
+ /*
+ * The file is still empty and we have an exlusive lock on it.
+ * Write out out SID data into the file.
+ */
+
+ if(fchmod(fd, 0644) < 0) {
+ DEBUG(0,("generate_machine_sid: unable to set correct permissions on file %s. \
Error was %s\n", sid_file, strerror(errno) ));
- close(fd);
- return False;
- }
-
- if(write( fd, sid_string, strlen(sid_string)) != strlen(sid_string)) {
- DEBUG(0,("generate_machine_sid: unable to write file %s. Error was %s\n",
- sid_file, strerror(errno) ));
- close(fd);
- return False;
- }
-
- /*
- * Unlock & exit.
- */
-
- do_file_lock( fd, 60, F_UNLCK);
- close(fd);
- return True;
+ close(fd);
+ return False;
+ }
+
+ if(write( fd, sid_string, strlen(sid_string)) != strlen(sid_string)) {
+ DEBUG(0,("generate_machine_sid: unable to write file %s. Error was %s\n",
+ sid_file, strerror(errno) ));
+ close(fd);
+ return False;
+ }
+
+ /*
+ * Unlock & exit.
+ */
+
+ do_file_lock( fd, 60, F_UNLCK);
+ close(fd);
+ return True;
}
/*******************************************************************
diff --git a/source3/passdb/smbpass.c b/source3/passdb/smbpass.c
index 9c811a3728..abdcb9eb50 100644
--- a/source3/passdb/smbpass.c
+++ b/source3/passdb/smbpass.c
@@ -953,5 +953,5 @@ struct passdb_ops *file_initialize_password_db(void)
#else
/* Do *NOT* make this function static. It breaks the compile on gcc. JRA */
- void dummy_function(void) { } /* stop some compilers complaining */
+ void smbpass_dummy_function(void) { } /* stop some compilers complaining */
#endif /* USE_SMBPASS_DB */
diff --git a/source3/passdb/smbpassfile.c b/source3/passdb/smbpassfile.c
index 3988fd1c78..efbbbd78bf 100644
--- a/source3/passdb/smbpassfile.c
+++ b/source3/passdb/smbpassfile.c
@@ -44,7 +44,7 @@ BOOL do_file_lock(int fd, int waitsecs, int type)
int ret;
gotalarm = 0;
- signal(SIGALRM, SIGNAL_CAST gotalarm_sig);
+ CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig);
lock.l_type = type;
lock.l_whence = SEEK_SET;
@@ -55,7 +55,7 @@ BOOL do_file_lock(int fd, int waitsecs, int type)
alarm(5);
ret = fcntl(fd, F_SETLKW, &lock);
alarm(0);
- signal(SIGALRM, SIGNAL_CAST SIG_DFL);
+ CatchSignal(SIGALRM, SIGNAL_CAST SIG_DFL);
if (gotalarm) {
DEBUG(0, ("do_file_lock: failed to %s file.\n",