From a4c72cfa9bbd5194fe8ea79cf0d996ec665c7ddb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Mar 2003 19:28:05 +0000 Subject: Fix module names (This used to be commit fa1c8eee1fdd2452f9e3595b2b3957ea8c0ea46a) --- source3/configure.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index ee6a88ee6d..4d607fbc8f 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3375,10 +3375,11 @@ fi ]) SMB_MODULE($MODULE_pdb_xml, pdb_xml, modules/xml.o, bin/xml.so PDB) SMB_MODULE($MODULE_pdb_mysql, pdb_mysql, modules/mysql.o, bin/mysql.so, PDB) -SMB_MODULE($MODULE_pdb_ldap, pdb_ldap, passdb/pdb_ldap.o, bin/pdb_ldap.so, PDB) +SMB_MODULE($MODULE_pdb_ldap, pdb_ldap, passdb/pdb_ldap.o, bin/ldapsam.so, PDB) SMB_MODULE($MODULE_pdb_smbpasswd, pdb_smbpasswd, passdb/pdb_smbpasswd.o, bin/smbpasswd.so, PDB) -SMB_MODULE($MODULE_pdb_tdb, pdb_tdbsam, passdb/pdb_tdb.o, bin/tdb.so, PDB) -SMB_MODULE($MODULE_pdb_nisplussam, pdb_nisplussam, passdb/pdb_nisplus.o, bin/nisplus.so, PDB) +SMB_MODULE($MODULE_pdb_tdb, pdb_tdbsam, passdb/pdb_tdb.o, bin/tdbsam.so, PDB) +SMB_MODULE($MODULE_pdb_nisplus, pdb_nisplussam, passdb/pdb_nisplus.o, bin/nisplussam.so, PDB) +SMB_MODULE($MODULE_pdb_unix, pdb_unixsam, passdb/pdb_unix.o, bin/unixsam.so, PDB) SMB_MODULE(STATIC, pdb_guest, passdb/pdb_guest.o, bin/pdb_guest.so, PDB) SMB_SUBSYSTEM(PDB) -- cgit From 84627f7995af6260e56f734a6d39ea1a85274c34 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 19 Mar 2003 19:32:51 +0000 Subject: replace pstrcpy (This used to be commit c6eb950b6879d7566ded33dd6a3853cf2d5310db) --- source3/nmbd/nmbd_elections.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c index 976abbed25..f09c37eedc 100644 --- a/source3/nmbd/nmbd_elections.c +++ b/source3/nmbd/nmbd_elections.c @@ -47,7 +47,7 @@ static void send_election_dgram(struct subnet_record *subrec, const char *workgr SIVAL(p,1,criterion); SIVAL(p,5,timeup*1000); /* ms - Despite what the spec says. */ p += 13; - pstrcpy(p,server_name); + safe_strcpy(p, server_name, sizeof(outbuf) - 1 - (p-outbuf)); strupper(p); p = skip_string(p,1); -- cgit From 2ffd83f3f0f91aef99cc8d6396dde917c9adf24f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Mar 2003 20:12:34 +0000 Subject: Fix build errors and move pdb_guest.so -> guest.so (This used to be commit 25412880251839de3dd17882fab30c873c886454) --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 4d607fbc8f..cffa75f163 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3380,7 +3380,7 @@ SMB_MODULE($MODULE_pdb_smbpasswd, pdb_smbpasswd, passdb/pdb_smbpasswd.o, bin/smb SMB_MODULE($MODULE_pdb_tdb, pdb_tdbsam, passdb/pdb_tdb.o, bin/tdbsam.so, PDB) SMB_MODULE($MODULE_pdb_nisplus, pdb_nisplussam, passdb/pdb_nisplus.o, bin/nisplussam.so, PDB) SMB_MODULE($MODULE_pdb_unix, pdb_unixsam, passdb/pdb_unix.o, bin/unixsam.so, PDB) -SMB_MODULE(STATIC, pdb_guest, passdb/pdb_guest.o, bin/pdb_guest.so, PDB) +SMB_MODULE(STATIC, pdb_guest, passdb/pdb_guest.o, bin/guest.so, PDB) SMB_SUBSYSTEM(PDB) SMB_MODULE($MODULE_rpc_lsa, rpc_lsa, \$(RPC_LSA_OBJ), bin/librpc_lsa.so, RPC) -- cgit From e14e43f3d3edda15872e0725cbefeadfa7aa8180 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Mar 2003 20:18:00 +0000 Subject: Fix pdb_unix usage - noticed by jmcd (This used to be commit dd03aec26dc39a4e56f18d547132768204a500db) --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index cffa75f163..fa8e99c3a4 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3379,7 +3379,7 @@ SMB_MODULE($MODULE_pdb_ldap, pdb_ldap, passdb/pdb_ldap.o, bin/ldapsam.so, PDB) SMB_MODULE($MODULE_pdb_smbpasswd, pdb_smbpasswd, passdb/pdb_smbpasswd.o, bin/smbpasswd.so, PDB) SMB_MODULE($MODULE_pdb_tdb, pdb_tdbsam, passdb/pdb_tdb.o, bin/tdbsam.so, PDB) SMB_MODULE($MODULE_pdb_nisplus, pdb_nisplussam, passdb/pdb_nisplus.o, bin/nisplussam.so, PDB) -SMB_MODULE($MODULE_pdb_unix, pdb_unixsam, passdb/pdb_unix.o, bin/unixsam.so, PDB) +SMB_MODULE($MODULE_pdb_unix, pdb_unix, passdb/pdb_unix.o, bin/unixsam.so, PDB) SMB_MODULE(STATIC, pdb_guest, passdb/pdb_guest.o, bin/guest.so, PDB) SMB_SUBSYSTEM(PDB) -- cgit From e542eedd18701fcc413e924b0a9787eec925dee6 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Wed, 19 Mar 2003 20:50:43 +0000 Subject: use strnlen to prevent coredumps (This used to be commit 1960a650c1546323708ed6bea615dc7215a97b4f) --- source3/lib/util_str.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 5157de0d91..d1e57ed5cf 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -495,7 +495,7 @@ char *safe_strcpy_fn(const char *fn, int line, char *dest,const char *src, size_ return dest; } - len = strlen(src); + len = strnlen(src, maxlength+1); if (len > maxlength) { DEBUG(0,("ERROR: string overflow by %u (%u - %u) in safe_strcpy [%.50s]\n", @@ -524,8 +524,8 @@ char *safe_strcat_fn(const char *fn, int line, char *dest, const char *src, size if (!src) return dest; - src_len = strlen(src); - dest_len = strlen(dest); + src_len = strnlen(src, maxlength + 1); + dest_len = strnlen(dest, maxlength + 1); clobber_region(fn, line, dest + dest_len, maxlength + 1 - dest_len); -- cgit From 9a328248aecbaf7554d93bad02314733ad988488 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Mar 2003 21:09:18 +0000 Subject: Fix corrupt memory reading in smb_register_passdb (This used to be commit 6acbb37e4e32de635ace8420a5182b04b6527e34) --- source3/passdb/pdb_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 9819df75ec..42310b41b0 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -53,7 +53,7 @@ BOOL smb_register_passdb(const char *name, pdb_init_function init, int version) } entry = smb_xmalloc(sizeof(struct pdb_init_function_entry)); - entry->name = name; + entry->name = smb_xstrdup(name); entry->init = init; DLIST_ADD(backends, entry); -- cgit From c775678250003ef2d9b3db4895a6654dd513b203 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 19 Mar 2003 22:16:38 +0000 Subject: Add make rules for passdb/*.so (This used to be commit ea85f8ff21bfad378eb8464a94bb182cb3e4f988) --- source3/Makefile.in | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 47c05191a3..27ca9c6f30 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -944,6 +944,31 @@ bin/mysql.@SHLIBEXT@: $(MYSQL_OBJ) @$(SHLD) $(LDSHFLAGS) -o $@ $(MYSQL_OBJ) @MYSQL_LIBS@ \ @SONAMEFLAG@`basename $@` +bin/ldapsam.@SHLIBEXT@: passdb/pdb_ldap.o + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_ldap.o \ + @SONAMEFLAG@`basename $@` + +bin/tdbsam.@SHLIBEXT@: passdb/pdb_tdb.o + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_tdb.o \ + @SONAMEFLAG@`basename $@` + +bin/smbpasswd.@SHLIBEXT@: passdb/pdb_smbpasswd.o + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_smbpasswd.o \ + @SONAMEFLAG@`basename $@` + +bin/unixsam.@SHLIBEXT@: passdb/pdb_unix.o + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_unix.o \ + @SONAMEFLAG@`basename $@` + +bin/nisplussam.@SHLIBEXT@: passdb/pdb_nisplus.o + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_nisplus.o \ + @SONAMEFLAG@`basename $@` + bin/developer.@SHLIBEXT@: $(DEVEL_HELP_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(DEVEL_HELP_OBJ) \ -- cgit From 2f13a74671c62a2861979ce2ab33ad1363bdbcf7 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 20 Mar 2003 00:32:44 +0000 Subject: Cleanup bogus initialisation in SID_NAME_USE enum. Added new sid type = 9 for "computer" from MSDN. (This used to be commit 45929d126932e5cac5a23fe76d28a4fa05b54b77) --- source3/include/smb.h | 16 ++++++++-------- source3/lib/util_sid.c | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/include/smb.h b/source3/include/smb.h index bf2d5631a7..0506c410f3 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -236,15 +236,15 @@ typedef struct nttime_info /* SID Types */ enum SID_NAME_USE { - SID_NAME_USE_NONE = 0,/* NOTUSED */ SID_NAME_USER = 1, /* user */ - SID_NAME_DOM_GRP = 2, /* domain group */ - SID_NAME_DOMAIN = 3, /* domain: don't know what this is */ - SID_NAME_ALIAS = 4, /* local group */ - SID_NAME_WKN_GRP = 5, /* well-known group */ - SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */ - SID_NAME_INVALID = 7, /* invalid account */ - SID_NAME_UNKNOWN = 8 /* oops. */ + SID_NAME_DOM_GRP, /* domain group */ + SID_NAME_DOMAIN, /* domain sid */ + SID_NAME_ALIAS, /* local group */ + SID_NAME_WKN_GRP, /* well-known group */ + SID_NAME_DELETED, /* deleted account: needed for c2 rating */ + SID_NAME_INVALID, /* invalid account */ + SID_NAME_UNKNOWN, /* unknown sid type */ + SID_NAME_COMPUTER, /* sid for a computer */ }; /** diff --git a/source3/lib/util_sid.c b/source3/lib/util_sid.c index 81d17ae3f2..dfd3b312e0 100644 --- a/source3/lib/util_sid.c +++ b/source3/lib/util_sid.c @@ -91,8 +91,9 @@ static const struct { {SID_NAME_DELETED, "Deleted Account"}, {SID_NAME_INVALID, "Invalid Account"}, {SID_NAME_UNKNOWN, "UNKNOWN"}, + {SID_NAME_COMPUTER, "Computer"}, - {SID_NAME_USE_NONE, NULL} + {0, NULL} }; const char *sid_type_lookup(uint32 sid_type) -- cgit From c8eed69be0850e7c68318562c91f73855a09dd92 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 20 Mar 2003 00:51:41 +0000 Subject: lib/messages.c: Check return from chainlock before modifying message queue. Apply the job returned limit across all requests for job queues. Jeremy. (This used to be commit dee1326a1d8a0bf8977df22a0fe014dd5d8dc769) --- source3/lib/messages.c | 4 +++- source3/printing/printing.c | 5 +++++ source3/rpc_server/srv_spoolss_nt.c | 6 ------ 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 5ff0e45c61..c078472880 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -315,7 +315,9 @@ static BOOL retrieve_all_messages(char **msgs_buf, size_t *total_len) kbuf = message_key_pid(sys_getpid()); - tdb_chainlock(tdb, kbuf); + if (tdb_chainlock(tdb, kbuf) == -1) + return False; + dbuf = tdb_fetch(tdb, kbuf); /* * Replace with an empty record to keep the allocated diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 26ea52e35a..99578975ca 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1959,6 +1959,7 @@ int print_queue_status(int snum, TDB_DATA data, key; const char *printername; struct tdb_print_db *pdb; + int max_reported_jobs = lp_max_reported_jobs(snum); /* make sure the database is up to date */ @@ -2033,6 +2034,10 @@ int print_queue_status(int snum, QSORT_CAST(printjob_comp)); *queue = tstruct.queue; + + if (max_reported_jobs && tstruct.qcount > max_reported_jobs) + tstruct.qcount = max_reported_jobs; + return tstruct.qcount; } diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 8073e3cf28..36ff92e46f 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -6353,7 +6353,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO int snum; print_status_struct prt_status; print_queue_struct *queue=NULL; - int max_rep_jobs; /* that's an [in out] buffer */ spoolss_move_buffer(q_u->buffer, &r_u->buffer); @@ -6367,8 +6366,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO if (!get_printer_snum(p, handle, &snum)) return WERR_BADFID; - max_rep_jobs = lp_max_reported_jobs(snum); - *returned = print_queue_status(snum, &queue, &prt_status); DEBUGADD(4,("count:[%d], status:[%d], [%s]\n", *returned, prt_status.status, prt_status.message)); @@ -6377,9 +6374,6 @@ WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJO return WERR_OK; } - if (max_rep_jobs && (*returned > max_rep_jobs)) - *returned = max_rep_jobs; - switch (level) { case 1: return enumjobs_level1(queue, snum, buffer, offered, needed, returned); -- cgit From c9167c943d24946066bbd62dbf33086a9a7bc3bd Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Thu, 20 Mar 2003 05:54:03 +0000 Subject: If CFLAGS is set when running configure, then just use that. Otherwise add -O. (We used to always set -O, which is sometimes annoying when debugging and anyhow clashes with normal autoconf behaviour.) (This used to be commit aee2ad9c3444d59dd6f53dda5379a6c391e00002) --- source3/configure.in | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index fa8e99c3a4..e6189aa06f 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -159,9 +159,6 @@ AC_SUBST(EXTRA_BIN_PROGS) AC_SUBST(EXTRA_SBIN_PROGS) AC_SUBST(EXTRA_ALL_TARGETS) -# compile with optimization and without debugging by default -CFLAGS="-O ${CFLAGS}" - AC_ARG_ENABLE(debug, [ --enable-debug Turn on compiler debugging information (default=no)], [if eval "test x$enable_debug = xyes"; then @@ -194,6 +191,13 @@ AC_PROG_INSTALL AC_PROG_AWK AC_PATH_PROG(PERL, perl) +# compile with optimization and without debugging by default, but +# allow people to set their own preference. +if test "x$CFLAGS" = x +then + CFLAGS="-O ${CFLAGS}" +fi + dnl Check if we use GNU ld LD=ld AC_PROG_LD_GNU -- cgit From d87feb3baffe62bbf8f709f6bb66e19b78abfb53 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2003 10:04:13 +0000 Subject: Merge Herb's change. Volker (This used to be commit e8725913f9f174c03683a35bbce16ee33ab4c707) --- source3/passdb/pdb_ldap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 98ddc72ed1..3373b6c838 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -2439,7 +2439,7 @@ static NTSTATUS ldapsam_setsamgrent(struct pdb_methods *my_methods, static void ldapsam_endsamgrent(struct pdb_methods *my_methods) { - return ldapsam_endsampwent(my_methods); + ldapsam_endsampwent(my_methods); } static NTSTATUS ldapsam_getsamgrent(struct pdb_methods *my_methods, -- cgit From 4e01382b3a655a1bfef1a73ad486344b842bcdfc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 11:11:32 +0000 Subject: Make swat use popt (This used to be commit 3cd1650d389850c2a36997a1a404d37bb28130e4) --- source3/Makefile.in | 7 ++++--- source3/web/swat.c | 27 +++++++++++++++------------ 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 27ca9c6f30..dc3e6d6fa2 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -363,7 +363,8 @@ SWAT_OBJ1 = web/cgi.o web/diagnose.o web/startstop.o web/statuspage.o \ SWAT_OBJ = $(SWAT_OBJ1) $(PRINTING_OBJ) $(LIBSMB_OBJ) $(LOCKING_OBJ) \ $(PARAM_OBJ) $(PASSDB_OBJ) $(SECRETS_OBJ) $(KRBCLIENT_OBJ) \ - $(UBIQX_OBJ) $(LIB_OBJ) $(GROUPDB_OBJ) $(PLAINTEXT_AUTH_OBJ) + $(UBIQX_OBJ) $(LIB_OBJ) $(GROUPDB_OBJ) $(PLAINTEXT_AUTH_OBJ) \ + $(POPT_LIB_OBJ) SMBSH_OBJ = smbwrapper/smbsh.o smbwrapper/shared.o \ $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) @@ -707,10 +708,10 @@ bin/wrepld@EXEEXT@: $(WREPL_OBJ) bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(WREPL_OBJ) $(LDFLAGS) $(LIBS) -bin/swat@EXEEXT@: $(SWAT_OBJ) bin/.dummy +bin/swat@EXEEXT@: $(SWAT_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) \ - $(AUTHLIBS) $(LIBS) + $(AUTHLIBS) $(LIBS) @BUILD_POPT@ bin/rpcclient@EXEEXT@: $(RPCCLIENT_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ diff --git a/source3/web/swat.c b/source3/web/swat.c index d6693b4e75..bece4e71e2 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -1261,10 +1261,16 @@ static void printers_page(void) **/ int main(int argc, char *argv[]) { - extern char *optarg; - extern int optind; int opt; char *page; + poptContext pc; + struct poptOption long_options[] = { + POPT_AUTOHELP + { "disable-authentication", 'a', POPT_ARG_VAL, &demo_mode, TRUE, "Disable authentication (demo mode)" }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, + { 0, 0, 0, 0 } + }; fault_setup(NULL); umask(S_IWGRP | S_IWOTH); @@ -1288,16 +1294,13 @@ static void printers_page(void) close(2); open("/dev/null", O_WRONLY); - while ((opt = getopt(argc, argv,"s:a")) != EOF) { - switch (opt) { - case 's': - pstrcpy(dyn_CONFIGFILE,optarg); - break; - case 'a': - demo_mode = True; - break; - } - } + pc = poptGetContext("swat", argc, (const char **) argv, long_options, 0); + + /* Parse command line options */ + + while((opt = poptGetNextOpt(pc)) != -1) { } + + poptFreeContext(pc); setup_logging(argv[0],False); load_config(True); -- cgit From 21fb0062071f71a617b4b6b7c626e74d354bde62 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 12:07:52 +0000 Subject: Convert smbcacls to popt (This used to be commit 45e5374e89730e7ad497edf9e344fbd1b8992589) --- source3/Makefile.in | 6 +-- source3/utils/smbcacls.c | 134 ++++++++++++++++++----------------------------- 2 files changed, 53 insertions(+), 87 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index dc3e6d6fa2..8a40525084 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -502,7 +502,7 @@ LOCKTEST2_OBJ = torture/locktest2.o $(LOCKING_OBJ) $(LIBSMB_OBJ) \ SMBCACLS_OBJ = utils/smbcacls.o $(LOCKING_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(PARAM_OBJ) \ $(UBIQX_OBJ) $(LIB_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_GET_SET_OBJ) \ - $(LIBMSRPC_OBJ) $(SECRETS_OBJ) + $(LIBMSRPC_OBJ) $(SECRETS_OBJ) $(POPT_LIB_OBJ) TALLOCTORT_OBJ = lib/talloctort.o $(LIB_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ) @@ -805,9 +805,9 @@ bin/msgtest@EXEEXT@: $(MSGTEST_OBJ) bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(MSGTEST_OBJ) $(LDFLAGS) $(LIBS) -bin/smbcacls@EXEEXT@: $(SMBCACLS_OBJ) bin/.dummy +bin/smbcacls@EXEEXT@: $(SMBCACLS_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBCACLS_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/locktest@EXEEXT@: $(LOCKTEST_OBJ) bin/.dummy @echo Linking $@ diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index bce64df960..9337eef106 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -28,7 +28,7 @@ static pstring username; static pstring owner_username; static fstring server; static int got_pass; -static int test_args; +static int test_args = FALSE; static TALLOC_CTX *ctx; #define CREATE_ACCESS_READ READ_CONTROL_ACCESS @@ -36,7 +36,7 @@ static TALLOC_CTX *ctx; /* numeric is set when the user wants numeric SIDs and ACEs rather than going via LSA calls to resolve them */ -static int numeric; +static BOOL numeric = FALSE; enum acl_mode {SMB_ACL_SET, SMB_ACL_DELETE, SMB_ACL_MODIFY, SMB_ACL_ADD }; enum chown_mode {REQUEST_NONE, REQUEST_CHOWN, REQUEST_CHGRP}; @@ -735,45 +735,37 @@ static struct cli_state *connect_one(const char *share) } } - -static void usage(void) -{ - printf( -"Usage: smbcacls //server1/share1 filename [options]\n\ -\n\ -\t-D delete an acl\n\ -\t-M modify an acl\n\ -\t-A add an acl\n\ -\t-S set acls\n\ -\t-C username change ownership of a file\n\ -\t-G username change group ownership of a file\n\ -\t-n don't resolve sids or masks to names\n\ -\t-h print help\n\ -\t-d debuglevel set debug output level\n\ -\t-U username user to autheticate as\n\ -\n\ -The username can be of the form username%%password or\n\ -workgroup\\username%%password.\n\n\ -An acl is of the form ACL::type/flags/mask\n\ -You can string acls together with spaces, commas or newlines\n\ -"); -} - /**************************************************************************** main program ****************************************************************************/ - int main(int argc,char *argv[]) + int main(int argc, const char *argv[]) { char *share; - pstring filename; - extern char *optarg; - extern int optind; int opt; char *p; enum acl_mode mode = SMB_ACL_SET; - char *the_acl = NULL; + static const char *the_acl = NULL; enum chown_mode change_mode = REQUEST_NONE; int result; + fstring path; + fstring filename; + poptContext pc; + struct poptOption long_options[] = { + POPT_AUTOHELP + { "delete", 'D', POPT_ARG_STRING, NULL, 'D', "Delete an acl", "ACL" }, + { "modify", 'M', POPT_ARG_STRING, NULL, 'M', "Modify an acl", "ACL" }, + { "add", 'A', POPT_ARG_STRING, NULL, 'A', "Add an acl", "ACL" }, + { "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls", "ACLS" }, + { "chown", 'C', POPT_ARG_STRING, NULL, 'C', "Change ownership of a file", "USERNAME" }, + { "chgrp", 'G', POPT_ARG_STRING, NULL, 'G', "Change group ownership of a file", "GROUPNAME" }, + { "numeric", 'n', POPT_ARG_VAL, &numeric, TRUE, "Don't resolve sids or masks to names" }, + { "test-args", 't', POPT_ARG_VAL, &test_args, TRUE, "Test arguments"}, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + {"username", 'U', POPT_ARG_STRING, NULL, 'U', "User to authenticate as", "user%password" }, + { NULL } + }; struct cli_state *cli; @@ -783,21 +775,8 @@ You can string acls together with spaces, commas or newlines\n\ dbf = x_stderr; - if (argc < 3 || argv[1][0] == '-') { - usage(); - talloc_destroy(ctx); - exit(EXIT_PARSE_ERROR); - } - setup_logging(argv[0],True); - share = argv[1]; - pstrcpy(filename, argv[2]); - all_string_sub(share,"/","\\",0); - - argc -= 2; - argv += 2; - lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); @@ -812,11 +791,14 @@ You can string acls together with spaces, commas or newlines\n\ strlen(password)); } } + pc = poptGetContext("smbcacls", argc, argv, long_options, 0); + + poptSetOtherOptionHelp(pc, "//server1/share1 filename [options]"); - while ((opt = getopt(argc, argv, "U:nhS:D:A:M:C:G:td:")) != EOF) { + while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case 'U': - pstrcpy(username,optarg); + pstrcpy(username,poptGetOptArg(pc)); p = strchr_m(username,'%'); if (p) { *p = 0; @@ -826,75 +808,60 @@ You can string acls together with spaces, commas or newlines\n\ break; case 'S': - the_acl = optarg; + the_acl = poptGetOptArg(pc); mode = SMB_ACL_SET; break; case 'D': - the_acl = optarg; + the_acl = poptGetOptArg(pc); mode = SMB_ACL_DELETE; break; case 'M': - the_acl = optarg; + the_acl = poptGetOptArg(pc); mode = SMB_ACL_MODIFY; break; case 'A': - the_acl = optarg; + the_acl = poptGetOptArg(pc); mode = SMB_ACL_ADD; break; case 'C': - pstrcpy(owner_username,optarg); + pstrcpy(owner_username,poptGetOptArg(pc)); change_mode = REQUEST_CHOWN; break; case 'G': - pstrcpy(owner_username,optarg); + pstrcpy(owner_username,poptGetOptArg(pc)); change_mode = REQUEST_CHGRP; break; - - case 'n': - numeric = 1; - break; - - case 't': - test_args = 1; - break; - - case 'h': - usage(); - talloc_destroy(ctx); - exit(EXIT_PARSE_ERROR); - - case 'd': - DEBUGLEVEL = atoi(optarg); - break; - - default: - printf("Unknown option %c (%d)\n", (char)opt, opt); - talloc_destroy(ctx); - exit(EXIT_PARSE_ERROR); } } - argc -= optind; - argv += optind; - - if (argc > 0) { - usage(); - talloc_destroy(ctx); - exit(EXIT_PARSE_ERROR); + /* Make connection to server */ + if(!poptPeekArg(pc)) { + poptPrintUsage(pc, stderr, 0); + return -1; } + + fstrcpy(path, poptGetArg(pc)); + + if(!poptPeekArg(pc)) { + poptPrintUsage(pc, stderr, 0); + return -1; + } + + fstrcpy(filename, poptGetArg(pc)); - /* Make connection to server */ + all_string_sub(path,"/","\\",0); - fstrcpy(server,share+2); + fstrcpy(server,path+2); share = strchr_m(server,'\\'); if (!share) { share = strchr_m(server,'/'); if (!share) { + printf("Invalid argument: %s\n", share); return -1; } } @@ -934,4 +901,3 @@ You can string acls together with spaces, commas or newlines\n\ return result; } - -- cgit From 56b6650b4e823da2af5c9655c695e57f49281e3e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2003 12:48:56 +0000 Subject: I like debug level 10, but these messages always get into my way when debugging pdc stuff... Volker (This used to be commit e1c275a66aa8a0fe29c61f4742fed5953671cb43) --- source3/passdb/pdb_get_set.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c index ed850b9f25..12e280578d 100644 --- a/source3/passdb/pdb_get_set.c +++ b/source3/passdb/pdb_get_set.c @@ -186,17 +186,17 @@ enum pdb_value_state pdb_get_init_flags (const SAM_ACCOUNT *sampass, enum pdb_el return ret; if (bitmap_query(sampass->private.set_flags, element)) { - DEBUG(10, ("element %d: SET\n", element)); + DEBUG(11, ("element %d: SET\n", element)); ret = PDB_SET; } if (bitmap_query(sampass->private.change_flags, element)) { - DEBUG(10, ("element %d: CHANGED\n", element)); + DEBUG(11, ("element %d: CHANGED\n", element)); ret = PDB_CHANGED; } if (ret == PDB_DEFAULT) { - DEBUG(10, ("element %d: DEFAULT\n", element)); + DEBUG(11, ("element %d: DEFAULT\n", element)); } return ret; @@ -479,7 +479,7 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p DEBUG(0,("Can't set flag: %d in set_falgs.\n",element)); return False; } - DEBUG(10, ("element %d -> now CHANGED\n", element)); + DEBUG(11, ("element %d -> now CHANGED\n", element)); break; case PDB_SET: if (!bitmap_clear(sampass->private.change_flags, element)) { @@ -502,7 +502,7 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p DEBUG(0,("Can't set flag: %d in set_falgs.\n",element)); return False; } - DEBUG(10, ("element %d -> now DEFAULT\n", element)); + DEBUG(11, ("element %d -> now DEFAULT\n", element)); break; } -- cgit From 3560c49e448d8be85d43200894eb681acb75cd4d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 20 Mar 2003 12:50:29 +0000 Subject: Fix typo (This used to be commit 5c6f5bef30db62f351d83ecdd6aa6990a567d842) --- source3/passdb/pdb_get_set.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c index 12e280578d..2efe720474 100644 --- a/source3/passdb/pdb_get_set.c +++ b/source3/passdb/pdb_get_set.c @@ -476,7 +476,7 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p return False; } if (!bitmap_set(sampass->private.set_flags, element)) { - DEBUG(0,("Can't set flag: %d in set_falgs.\n",element)); + DEBUG(0,("Can't set flag: %d in set_flags.\n",element)); return False; } DEBUG(11, ("element %d -> now CHANGED\n", element)); @@ -487,7 +487,7 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p return False; } if (!bitmap_set(sampass->private.set_flags, element)) { - DEBUG(0,("Can't set flag: %d in set_falgs.\n",element)); + DEBUG(0,("Can't set flag: %d in set_flags.\n",element)); return False; } DEBUG(10, ("element %d -> now SET\n", element)); @@ -499,7 +499,7 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p return False; } if (!bitmap_clear(sampass->private.set_flags, element)) { - DEBUG(0,("Can't set flag: %d in set_falgs.\n",element)); + DEBUG(0,("Can't set flag: %d in set_flags.\n",element)); return False; } DEBUG(11, ("element %d -> now DEFAULT\n", element)); -- cgit From bcc8bb40e01c4f1aa86adfa8a0e1c7586e699ad2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 13:21:23 +0000 Subject: Use True, not TRUE and False, not FALSE (This used to be commit 44e9bf88cc2bbb2aa34711354258c3abb319cb9b) --- source3/passdb/pdb_interface.c | 2 +- source3/passdb/pdb_ldap.c | 2 +- source3/passdb/pdb_smbpasswd.c | 2 +- source3/utils/smbcacls.c | 8 ++++---- source3/web/swat.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index 42310b41b0..b146951561 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -31,7 +31,7 @@ static void lazy_initialize_passdb(void) static BOOL initialized = FALSE; if(initialized)return; static_init_pdb; - initialized = TRUE; + initialized = True; } BOOL smb_register_passdb(const char *name, pdb_init_function init, int version) diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 3373b6c838..375fbeacc5 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -2614,5 +2614,5 @@ int pdb_ldap_init(void) { smb_register_passdb("ldapsam", pdb_init_ldapsam, PASSDB_INTERFACE_VERSION); smb_register_passdb("ldapsam_nua", pdb_init_ldapsam_nua, PASSDB_INTERFACE_VERSION); - return TRUE; + return True; } diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index bcbeb74808..7f74196633 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -1584,5 +1584,5 @@ int pdb_smbpasswd_init(void) { smb_register_passdb("smbpasswd", pdb_init_smbpasswd, PASSDB_INTERFACE_VERSION); smb_register_passdb("smbpasswd_nua", pdb_init_smbpasswd_nua, PASSDB_INTERFACE_VERSION); - return TRUE; + return True; } diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index 9337eef106..4588389f75 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -28,7 +28,7 @@ static pstring username; static pstring owner_username; static fstring server; static int got_pass; -static int test_args = FALSE; +static int test_args = False; static TALLOC_CTX *ctx; #define CREATE_ACCESS_READ READ_CONTROL_ACCESS @@ -36,7 +36,7 @@ static TALLOC_CTX *ctx; /* numeric is set when the user wants numeric SIDs and ACEs rather than going via LSA calls to resolve them */ -static BOOL numeric = FALSE; +static BOOL numeric = False; enum acl_mode {SMB_ACL_SET, SMB_ACL_DELETE, SMB_ACL_MODIFY, SMB_ACL_ADD }; enum chown_mode {REQUEST_NONE, REQUEST_CHOWN, REQUEST_CHGRP}; @@ -758,8 +758,8 @@ static struct cli_state *connect_one(const char *share) { "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls", "ACLS" }, { "chown", 'C', POPT_ARG_STRING, NULL, 'C', "Change ownership of a file", "USERNAME" }, { "chgrp", 'G', POPT_ARG_STRING, NULL, 'G', "Change group ownership of a file", "GROUPNAME" }, - { "numeric", 'n', POPT_ARG_VAL, &numeric, TRUE, "Don't resolve sids or masks to names" }, - { "test-args", 't', POPT_ARG_VAL, &test_args, TRUE, "Test arguments"}, + { "numeric", 'n', POPT_ARG_VAL, &numeric, True, "Don't resolve sids or masks to names" }, + { "test-args", 't', POPT_ARG_VAL, &test_args, True, "Test arguments"}, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, diff --git a/source3/web/swat.c b/source3/web/swat.c index bece4e71e2..92dece6ecd 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -1266,7 +1266,7 @@ static void printers_page(void) poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP - { "disable-authentication", 'a', POPT_ARG_VAL, &demo_mode, TRUE, "Disable authentication (demo mode)" }, + { "disable-authentication", 'a', POPT_ARG_VAL, &demo_mode, True, "Disable authentication (demo mode)" }, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, { 0, 0, 0, 0 } -- cgit From 6798444ba5de8424578823aaf85b3fd9c65cc4f6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 13:59:58 +0000 Subject: Build samr as well (This used to be commit 1d33afdef9ea11e17c633109170d35ed66c4e2b8) --- source3/configure.in | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index e6189aa06f..958771368e 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3394,6 +3394,7 @@ SMB_MODULE($MODULE_rpc_netlog, rpc_net, \$(RPC_NETLOG_OBJ), bin/librpc_netlog.so SMB_MODULE($MODULE_rpc_dfs, rpc_dfs, \$(RPC_DFS_OBJ), bin/librpc_dfs.so, RPC) SMB_MODULE($MODULE_rpc_srv, rpc_srv, \$(RPC_SVC_OBJ), bin/librpc_srvsvc.so, RPC) SMB_MODULE($MODULE_rpc_spoolss, rpc_spoolss, \$(RPC_SPOOLSS_OBJ), bin/librpc_spoolss.so, RPC) +SMB_MODULE($MODULE_rpc_samr, rpc_samr, \$(RPC_SAMR_OBJ), bin/librpc_samr.so, RPC) SMB_SUBSYSTEM(RPC) ################################################# -- cgit From 29d734a93cf3baa902502852bd246b387d6e8f93 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Thu, 20 Mar 2003 14:39:46 +0000 Subject: use pstrcpy_base() (This used to be commit 9387caf3cebecd50de2b295560355b779135d8c3) --- source3/nmbd/nmbd_elections.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/nmbd/nmbd_elections.c b/source3/nmbd/nmbd_elections.c index f09c37eedc..339a27d207 100644 --- a/source3/nmbd/nmbd_elections.c +++ b/source3/nmbd/nmbd_elections.c @@ -47,7 +47,7 @@ static void send_election_dgram(struct subnet_record *subrec, const char *workgr SIVAL(p,1,criterion); SIVAL(p,5,timeup*1000); /* ms - Despite what the spec says. */ p += 13; - safe_strcpy(p, server_name, sizeof(outbuf) - 1 - (p-outbuf)); + pstrcpy_base(p, server_name, outbuf); strupper(p); p = skip_string(p,1); -- cgit From be40463c310ccc32d6a767a1521a87da937d6971 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 14:49:37 +0000 Subject: Fix compile errors - don't use pstrcpy() on a fstring (This used to be commit 3bad73ca870bb43324bdb5dfc6bb02e0fa1fb1e0) --- source3/utils/smbcacls.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index 4588389f75..b523ac9423 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -5,6 +5,7 @@ Copyright (C) Andrew Tridgell 2000 Copyright (C) Tim Potter 2000 Copyright (C) Jeremy Allison 2000 + Copyright (C) Jelmer Vernooij 2003 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 @@ -744,11 +745,11 @@ static struct cli_state *connect_one(const char *share) int opt; char *p; enum acl_mode mode = SMB_ACL_SET; - static const char *the_acl = NULL; + static char *the_acl = NULL; enum chown_mode change_mode = REQUEST_NONE; int result; fstring path; - fstring filename; + pstring filename; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP @@ -808,22 +809,22 @@ static struct cli_state *connect_one(const char *share) break; case 'S': - the_acl = poptGetOptArg(pc); + the_acl = smb_xstrdup(poptGetOptArg(pc)); mode = SMB_ACL_SET; break; case 'D': - the_acl = poptGetOptArg(pc); + the_acl = smb_xstrdup(poptGetOptArg(pc)); mode = SMB_ACL_DELETE; break; case 'M': - the_acl = poptGetOptArg(pc); + the_acl = smb_xstrdup(poptGetOptArg(pc)); mode = SMB_ACL_MODIFY; break; case 'A': - the_acl = poptGetOptArg(pc); + the_acl = smb_xstrdup(poptGetOptArg(pc)); mode = SMB_ACL_ADD; break; @@ -852,7 +853,7 @@ static struct cli_state *connect_one(const char *share) return -1; } - fstrcpy(filename, poptGetArg(pc)); + pstrcpy(filename, poptGetArg(pc)); all_string_sub(path,"/","\\",0); -- cgit From 9ba6be2e703e92971c8102f55fd840ef24ecf208 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 15:45:27 +0000 Subject: Fix setOtherHelp() - pointed out by metze (This used to be commit 05b1681b03688c0d4e57e8dfb881b111f947e6c6) --- source3/utils/smbcacls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index b523ac9423..af5bf09e48 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -794,7 +794,7 @@ static struct cli_state *connect_one(const char *share) } pc = poptGetContext("smbcacls", argc, argv, long_options, 0); - poptSetOtherOptionHelp(pc, "//server1/share1 filename [options]"); + poptSetOtherOptionHelp(pc, "//server1/share1 filename"); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { -- cgit From c7e720c87bf1dae8ec4ca4bad47a7324c89b7c05 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 16:42:39 +0000 Subject: Patch from Samuel Thibault to convert messages from unix to dos charset. Works on 2000. sending messages to 9x needs to be fixed, but that didn't work anyway (This used to be commit ca066502a2a3dbdd8943d515c9c6d21e62d757b6) --- source3/lib/charcnv.c | 2 +- source3/libsmb/climessage.c | 17 ++++++++++++++--- source3/smbd/message.c | 27 ++++++++++++++++++--------- 3 files changed, 33 insertions(+), 13 deletions(-) (limited to 'source3') diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c index fa646573d8..42cba33483 100644 --- a/source3/lib/charcnv.c +++ b/source3/lib/charcnv.c @@ -186,7 +186,7 @@ size_t convert_string(charset_t from, charset_t to, * @returns Size in bytes of the converted string; or -1 in case of error. **/ -static size_t convert_string_allocate(charset_t from, charset_t to, +size_t convert_string_allocate(charset_t from, charset_t to, void const *src, size_t srclen, void **dest) { size_t i_len, o_len, destlen; diff --git a/source3/libsmb/climessage.c b/source3/libsmb/climessage.c index 1587e6f4cd..5f6ce36133 100644 --- a/source3/libsmb/climessage.c +++ b/source3/libsmb/climessage.c @@ -65,6 +65,8 @@ send a message ****************************************************************************/ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) { + char *msgdos; + int lendos; char *p; memset(cli->outbuf,'\0',smb_size); @@ -77,9 +79,18 @@ BOOL cli_message_text(struct cli_state *cli, char *msg, int len, int grp) p = smb_buf(cli->outbuf); *p++ = 1; - SSVAL(p,0,len); p += 2; - memcpy(p,msg,len); - p += len; + + if ((lendos = convert_string_allocate(CH_UNIX, CH_DOS, msg,len, (void **) &msgdos)) < 0 || !msgdos) { + DEBUG(3,("Conversion failed, sending message in UNIX charset\n")); + SSVAL(p, 0, len); p += 2; + memcpy(p, msg, len); + p += len; + } else { + SSVAL(p, 0, lendos); p += 2; + memcpy(p, msgdos, lendos); + p += lendos; + SAFE_FREE(msgdos); + } cli_setup_bcc(cli, p); cli_send_smb(cli); diff --git a/source3/smbd/message.c b/source3/smbd/message.c index ba646f12aa..233848d2d6 100644 --- a/source3/smbd/message.c +++ b/source3/smbd/message.c @@ -41,6 +41,8 @@ static void msg_deliver(void) pstring name; int i; int fd; + char *msg; + int len; if (! (*lp_msg_command())) { @@ -61,16 +63,23 @@ static void msg_deliver(void) /* * Incoming message is in DOS codepage format. Convert to UNIX. */ - - if(msgpos > 0) { - msgbuf[msgpos] = '\0'; /* Ensure null terminated. */ - } - - for (i=0;i Date: Thu, 20 Mar 2003 16:53:07 +0000 Subject: NT4 as well as W2k respond with IPC regardless of what service type the client requested in the TCONX when connecting to IPC$. It is very well possible that this also applies to the DISK and PRINTER share types, not only IPC. Found this while trying to join a HEAD domain from NT4SP6. Volker (This used to be commit d42eb2116df4bb82c4199a688a057cd0a9f435ed) --- source3/smbd/reply.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 138870453d..715bace152 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -276,7 +276,7 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt set_message(outbuf,3,0,True); p = smb_buf(outbuf); - p += srvstr_push(outbuf, p, devicename, -1, + p += srvstr_push(outbuf, p, IS_IPC(conn) ? "IPC" : devicename, -1, STR_TERMINATE|STR_ASCII); p += srvstr_push(outbuf, p, fsname, -1, STR_TERMINATE); -- cgit From 5c913362dcc2a7d64335a43ae03867aa9e6beef4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 20 Mar 2003 17:45:23 +0000 Subject: Only build pdb_ldap if both ldap libs and headers are found (This used to be commit 228110e83fce91c811c82f6f836d313b6b79ff87) --- source3/configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 958771368e..b6fabe6085 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -472,7 +472,7 @@ AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/i AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h) AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h) AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h) -AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h ldap.h lber.h dlfcn.h) +AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h dlfcn.h) AC_CHECK_HEADERS(sys/syslog.h syslog.h) # In valgrind 1.0.x, it's just valgrind.h. In 1.9.x+ there's a @@ -2247,7 +2247,7 @@ if test x"$with_ldap_support" = x"yes"; then if test x$have_ldap != xyes; then AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap"; AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])]) - default_modules="$default_modules pdb_ldap" + AC_CHECK_HEADERS([ldap.h lber.h], [default_modules="$default_modules pdb_ldap"]) ######################################################## # If we have LDAP, does it's rebind procedure take 2 or 3 arguments? -- cgit From 677838b9997d89dc53c9b5b9a3601c0bc2cbdf80 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 21 Mar 2003 13:28:06 +0000 Subject: Give volker a hand, and let domain joins with existing user accounts work a bit better. This just sets the minimum possible attributes - if we are 'upgrading' an LDAP based user account, the attributes will be there anyway. This matches NT pretty well to. This also fixes some use of unitialised values in the desired_access checking. (found by valgrind). Andrew Bartlett (This used to be commit 929213ff2a5829ba8435ba1be0de317bca1e0da0) --- source3/rpc_server/srv_samr_nt.c | 50 ++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index d766e9c19e..7448dc6401 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -81,6 +81,7 @@ NTSTATUS access_check_samr_object(SEC_DESC *psd, NT_USER_TOKEN *nt_user_token, u NTSTATUS status = NT_STATUS_ACCESS_DENIED; if (!se_access_check(psd, nt_user_token, des_access, acc_granted, &status)) { + *acc_granted = des_access; if (geteuid() == sec_initial_uid()) { DEBUG(4,("%s: ACCESS should be DENIED (requested: %#010x)\n", debug, des_access)); @@ -2199,7 +2200,7 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ uint32 acc_granted; SEC_DESC *psd; size_t sd_size; - uint32 des_access; + uint32 des_access = GENERIC_RIGHTS_USER_ALL_ACCESS; /* Get the domain SID stored in the domain policy */ if (!get_lsa_policy_samr_sid(p, &dom_pol, &sid, &acc_granted)) @@ -2284,25 +2285,50 @@ NTSTATUS _api_samr_create_user(pipes_struct *p, SAMR_Q_CREATE_USER *q_u, SAMR_R_ DEBUG(3,("_api_samr_create_user: Running the command `%s' gave %d\n", add_script, add_ret)); } + if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { + return nt_status; + } + pw = getpwnam_alloc(account); if (pw) { - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_pw(&sam_pass, pw))) { - passwd_free(&pw); - return nt_status; + DOM_SID user_sid; + DOM_SID group_sid; + if (!uid_to_sid(&user_sid, pw->pw_uid)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + DEBUG(1, ("_api_samr_create_user: uid_to_sid failed, cannot add user.\n")); + return NT_STATUS_ACCESS_DENIED; } - passwd_free(&pw); /* done with this now */ - } else { - DEBUG(3,("attempting to create non-unix account %s\n", account)); - - if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sam_pass))) { - return nt_status; + + if (!pdb_set_user_sid(sam_pass, &user_sid, PDB_CHANGED)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_MEMORY; } - - if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { + + if (!gid_to_sid(&group_sid, pw->pw_gid)) { + passwd_free(&pw); /* done with this now */ + pdb_free_sam(&sam_pass); + DEBUG(1, ("_api_samr_create_user: gid_to_sid failed, cannot add user.\n")); + return NT_STATUS_ACCESS_DENIED; + } + + if (!pdb_set_group_sid(sam_pass, &group_sid, PDB_CHANGED)) { + passwd_free(&pw); /* done with this now */ pdb_free_sam(&sam_pass); return NT_STATUS_NO_MEMORY; } + + passwd_free(&pw); /* done with this now */ + } else { + DEBUG(3,("attempting to create non-unix account %s\n", account)); + + } + + if (!pdb_set_username(sam_pass, account, PDB_CHANGED)) { + pdb_free_sam(&sam_pass); + return NT_STATUS_NO_MEMORY; } pdb_set_acct_ctrl(sam_pass, acb_info, PDB_CHANGED); -- cgit From 940a114058de6488bc4212a006442fe2899a5f0a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 21 Mar 2003 21:43:54 +0000 Subject: Add more mappings to the nterr->errno mapping table. It should be fairly complete now. (This used to be commit 72bb5615f3eef1c5b27716dfcabe4c8288729458) --- source3/libsmb/clierror.c | 78 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 12a7b5dba1..3889976070 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. client error handling routines Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) Jelmer Vernooij 2003 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 @@ -220,16 +221,87 @@ static struct { int error; } nt_errno_map[] = { {NT_STATUS_ACCESS_VIOLATION, EACCES}, - {NT_STATUS_NO_SUCH_FILE, ENOENT}, - {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, {NT_STATUS_INVALID_HANDLE, EBADF}, - {NT_STATUS_NO_MEMORY, ENOMEM}, {NT_STATUS_ACCESS_DENIED, EACCES}, {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT}, {NT_STATUS_SHARING_VIOLATION, EBUSY}, {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR}, {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST}, {NT_STATUS_PATH_NOT_COVERED, ENOENT}, + {NT_STATUS_UNSUCCESSFUL, EINVAL}, + {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, + {NT_STATUS_IN_PAGE_ERROR, EFAULT}, + {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, + {NT_STATUS_TIMER_NOT_CANCELED, ETIME}, + {NT_STATUS_INVALID_PARAMETER, EINVAL}, + {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, + {NT_STATUS_NO_SUCH_FILE, ENOENT}, + {NT_STATUS_END_OF_FILE, ENODATA}, + {NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM}, + {NT_STATUS_NONEXISTENT_SECTOR, ESPIPE}, + {NT_STATUS_NO_MEMORY, ENOMEM}, + {NT_STATUS_CONFLICTING_ADDRESSES, EADDRINUSE}, + {NT_STATUS_NOT_MAPPED_VIEW, EINVAL}, + {NT_STATUS_UNABLE_TO_FREE_VM, EADDRINUSE}, + {NT_STATUS_ACCESS_DENIED, EACCES}, + {NT_STATUS_BUFFER_TOO_SMALL, ENOBUFS}, + {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, + {NT_STATUS_WRONG_PASSWORD, EACCES}, + {NT_STATUS_LOGON_FAILURE, EACCES}, + {NT_STATUS_INVALID_WORKSTATION, EACCES}, + {NT_STATUS_INVALID_LOGON_HOURS, EACCES}, + {NT_STATUS_PASSWORD_EXPIRED, EACCES}, + {NT_STATUS_ACCOUNT_DISABLED, EACCES}, + {NT_STATUS_DISK_FULL, ENOSPC}, + {NT_STATUS_INVALID_PIPE_STATE, EPIPE}, + {NT_STATUS_PIPE_BUSY, EPIPE}, + {NT_STATUS_PIPE_DISCONNECTED, EPIPE}, + {NT_STATUS_PIPE_NOT_AVAILABLE, ENOSYS}, + {NT_STATUS_FILE_IS_A_DIRECTORY, EISDIR}, + {NT_STATUS_NOT_SUPPORTED, ENOSYS}, + {NT_STATUS_NOT_A_DIRECTORY, ENOTDIR}, + {NT_STATUS_DIRECTORY_NOT_EMPTY, ENOTEMPTY}, + {NT_STATUS_NETWORK_UNREACHABLE, ENETUNREACH}, + {NT_STATUS_HOST_UNREACHABLE, EHOSTUNREACH}, + {NT_STATUS_CONNECTION_ABORTED, ECONNABORTED}, + {NT_STATUS_CONNECTION_REFUSED, ECONNREFUSED}, + {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT}, + {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT}, + {NT_STATUS_TOO_MANY_LINKS, EMLINK}, + {NT_STATUS_NETWORK_BUSY, EBUSY}, + {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV}, + {NT_STATUS_DLL_NOT_FOUND, ELIBACC}, + {NT_STATUS_PIPE_BROKEN, EPIPE}, + {NT_STATUS_REMOTE_NOT_LISTENING, ECONNREFUSED}, + {NT_STATUS_NETWORK_ACCESS_DENIED, EACCES}, + {NT_STATUS_TOO_MANY_OPENED_FILES, EMFILE}, + {NT_STATUS_DEVICE_PROTOCOL_ERROR, EPROTO}, + {NT_STATUS_NO_MEDIA, ENOMEDIUM}, + {NT_STATUS_FLOAT_OVERFLOW, ERANGE}, + {NT_STATUS_FLOAT_UNDERFLOW, ERANGE}, + {NT_STATUS_INTEGER_OVERFLOW, ERANGE}, + {NT_STATUS_MEDIA_WRITE_PROTECTED, EROFS}, + {NT_STATUS_PIPE_CONNECTED, EISCONN}, + {NT_STATUS_MEMORY_NOT_ALLOCATED, EFAULT}, + {NT_STATUS_FLOAT_INEXACT_RESULT, ERANGE}, + {NT_STATUS_ILL_FORMED_PASSWORD, EACCES}, + {NT_STATUS_PASSWORD_RESTRICTION, EACCES}, + {NT_STATUS_ACCOUNT_RESTRICTION, EACCES}, + {NT_STATUS_PORT_CONNECTION_REFUSED, ECONNREFUSED}, + {NT_STATUS_NAME_TOO_LONG, ENAMETOOLONG}, + {NT_STATUS_REMOTE_DISCONNECT, ESHUTDOWN}, + {NT_STATUS_CONNECTION_DISCONNECTED, ECONNABORTED}, + {NT_STATUS_CONNECTION_RESET, ENETRESET}, + {NT_STATUS_IP_ADDRESS_CONFLICT1, ENOTUNIQ}, + {NT_STATUS_IP_ADDRESS_CONFLICT2, ENOTUNIQ}, + {NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE}, + {NT_STATUS_PROTOCOL_UNREACHABLE, ENOPROTOOPT}, + {NT_STATUS_ADDRESS_ALREADY_EXISTS, EADDRINUSE}, + {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH}, + {NT_STATUS_IO_TIMEOUT, ETIMEDOUT}, + {NT_STATUS_RETRY, EAGAIN}, + {NT_STATUS_NET_WRITE_FAULT, ECOMM}, + {NT_STATUS(0), 0} }; -- cgit From 522cc6781f9b0acd88166fc25e6e3ebe58a322ce Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 21 Mar 2003 22:00:19 +0000 Subject: Merge of new appliance-head scalable printing fixes. Jeremy. (This used to be commit 301f17df51961b645b63d1520fc9c2e5627c1a0a) --- source3/printing/printing.c | 429 +++++++++++++++++++++++++++++--------------- 1 file changed, 287 insertions(+), 142 deletions(-) (limited to 'source3') diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 99578975ca..da29eab9f2 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -246,20 +246,22 @@ int unpack_pjob( char* buf, int buflen, struct printjob *pjob ) { int len = 0; int used; - + uint32 pjpid, pjsysjob, pjfd, pjstarttime, pjstatus; + uint32 pjsize, pjpage_count, pjspooled, pjsmbjob; + if ( !buf || !pjob ) return -1; len += tdb_unpack(buf+len, buflen-len, "dddddddddffff", - &pjob->pid, - &pjob->sysjob, - &pjob->fd, - &pjob->starttime, - &pjob->status, - &pjob->size, - &pjob->page_count, - &pjob->spooled, - &pjob->smbjob, + &pjpid, + &pjsysjob, + &pjfd, + &pjstarttime, + &pjstatus, + &pjsize, + &pjpage_count, + &pjspooled, + &pjsmbjob, pjob->filename, pjob->jobname, pjob->user, @@ -272,6 +274,16 @@ int unpack_pjob( char* buf, int buflen, struct printjob *pjob ) return -1; len += used; + + pjob->pid = pjpid; + pjob->sysjob = pjsysjob; + pjob->fd = pjfd; + pjob->starttime = pjstarttime; + pjob->status = pjstatus; + pjob->size = pjsize; + pjob->page_count = pjpage_count; + pjob->spooled = pjspooled; + pjob->smbjob = pjsmbjob; return len; @@ -464,15 +476,15 @@ static BOOL pjob_store(int snum, uint32 jobid, struct printjob *pjob) len = 0; buflen = newlen; len += tdb_pack(buf+len, buflen-len, "dddddddddffff", - pjob->pid, - pjob->sysjob, - pjob->fd, - pjob->starttime, - pjob->status, - pjob->size, - pjob->page_count, - pjob->spooled, - pjob->smbjob, + (uint32)pjob->pid, + (uint32)pjob->sysjob, + (uint32)pjob->fd, + (uint32)pjob->starttime, + (uint32)pjob->status, + (uint32)pjob->size, + (uint32)pjob->page_count, + (uint32)pjob->spooled, + (uint32)pjob->smbjob, pjob->filename, pjob->jobname, pjob->user, @@ -782,6 +794,84 @@ static void set_updating_pid(const fstring printer_name, BOOL delete) release_print_db(pdb); } +/**************************************************************************** + Sort print jobs by submittal time. +****************************************************************************/ + +static int printjob_comp(print_queue_struct *j1, print_queue_struct *j2) +{ + /* Silly cases */ + + if (!j1 && !j2) + return 0; + if (!j1) + return -1; + if (!j2) + return 1; + + /* Sort on job start time */ + + if (j1->time == j2->time) + return 0; + return (j1->time > j2->time) ? 1 : -1; +} + +/**************************************************************************** + Store the sorted queue representation for later portmon retrieval. +****************************************************************************/ + +static void store_queue_struct(struct tdb_print_db *pdb, struct traverse_struct *pts) +{ + TDB_DATA data, key; + int max_reported_jobs = lp_max_reported_jobs(pts->snum); + print_queue_struct *queue = pts->queue; + size_t len; + size_t i; + uint qcount; + + if (max_reported_jobs < pts->qcount) + pts->qcount = max_reported_jobs; + qcount = pts->qcount; + + /* Work out the size. */ + data.dsize = 0; + data.dsize += tdb_pack(NULL, 0, NULL, "d", qcount); + + for (i = 0; i < pts->qcount; i++) { + data.dsize += tdb_pack(NULL, 0, NULL, "ddddddff", + (uint32)queue[i].job, + (uint32)queue[i].size, + (uint32)queue[i].page_count, + (uint32)queue[i].status, + (uint32)queue[i].priority, + (uint32)queue[i].time, + queue[i].fs_user, + queue[i].fs_file); + } + + if ((data.dptr = malloc(data.dsize)) == NULL) + return; + + len = 0; + len += tdb_pack(data.dptr + len, data.dsize - len, NULL, "d", qcount); + for (i = 0; i < pts->qcount; i++) { + len += tdb_pack(data.dptr + len, data.dsize - len, NULL, "ddddddff", + (uint32)queue[i].job, + (uint32)queue[i].size, + (uint32)queue[i].page_count, + (uint32)queue[i].status, + (uint32)queue[i].priority, + (uint32)queue[i].time, + queue[i].fs_user, + queue[i].fs_file); + } + + key.dptr = "INFO/linear_queue_array"; + key.dsize = strlen(key.dptr); + tdb_store(pdb->tdb, key, data, TDB_REPLACE); + return; +} + /**************************************************************************** Update the internal database from the system print queue for a queue. ****************************************************************************/ @@ -869,6 +959,12 @@ static void print_queue_update(int snum) DEBUG(3, ("%d job%s in queue for %s\n", qcount, (qcount != 1) ? "s" : "", printer_name)); + /* Sort the queue by submission time otherwise they are displayed + in hash order. */ + + qsort(queue, qcount, sizeof(print_queue_struct), + QSORT_CAST(printjob_comp)); + /* any job in the internal database that is marked as spooled and doesn't exist in the system queue is considered finished @@ -914,6 +1010,9 @@ static void print_queue_update(int snum) tdb_traverse(pdb->tdb, traverse_fn_delete, (void *)&tstruct); + /* Store the linearised queue, max jobs only. */ + store_queue_struct(pdb, &tstruct); + SAFE_FREE(tstruct.queue); DEBUG(10,("print_queue_update: printer %s INFO/total_jobs = %d\n", @@ -1216,6 +1315,58 @@ BOOL print_job_set_name(int snum, uint32 jobid, char *name) return pjob_store(snum, jobid, pjob); } +/*************************************************************************** + Remove a jobid from the 'jobs changed' list. +***************************************************************************/ + +static BOOL remove_from_jobs_changed(int snum, uint32 jobid) +{ + const char *printername = lp_const_servicename(snum); + struct tdb_print_db *pdb = get_print_db_byname(printername); + TDB_DATA data, key; + size_t job_count, i; + BOOL ret = False; + BOOL gotlock = False; + + key.dptr = "INFO/jobs_changed"; + key.dsize = strlen(key.dptr); + ZERO_STRUCT(data); + + if (tdb_chainlock_with_timeout(pdb->tdb, key, 5) == -1) + goto out; + + gotlock = True; + + data = tdb_fetch(pdb->tdb, key); + + if (data.dptr == NULL || data.dsize == 0 || (data.dsize % 4 != 0)) + goto out; + + job_count = data.dsize / 4; + for (i = 0; i < job_count; i++) { + uint32 ch_jobid; + + memcpy(&ch_jobid, data.dptr + (i*4), 4); + if (ch_jobid == jobid) { + if (i < job_count -1 ) + memmove(data.dptr + (i*4), data.dptr + (i*4) + 4, (job_count - i - 1)*4 ); + data.dsize -= 4; + if (tdb_store(pdb->tdb, key, data, TDB_REPLACE) == -1) + goto out; + break; + } + } + + ret = True; + out: + + if (gotlock) + tdb_chainunlock(pdb->tdb, key); + SAFE_FREE(data.dptr); + release_print_db(pdb); + return ret; +} + /**************************************************************************** Delete a print job - don't update queue. ****************************************************************************/ @@ -1249,6 +1400,8 @@ static BOOL print_job_delete1(int snum, uint32 jobid) if (pjob->spooled && pjob->sysjob != -1) result = (*(current_printif->job_delete))(snum, pjob); + else + remove_from_jobs_changed(snum, jobid); /* Delete the tdb entry if the delete suceeded or the job hasn't been spooled. */ @@ -1624,6 +1777,22 @@ static BOOL allocate_print_jobid(struct tdb_print_db *pdb, int snum, const char return True; } +/*************************************************************************** + Append a jobid to the 'jobs changed' list. +***************************************************************************/ + +static BOOL add_to_jobs_changed(struct tdb_print_db *pdb, uint32 jobid) +{ + TDB_DATA data, key; + + key.dptr = "INFO/jobs_changed"; + key.dsize = strlen(key.dptr); + data.dptr = (char *)&jobid; + data.dsize = 4; + + return (tdb_append(pdb->tdb, key, data) == 0); +} + /*************************************************************************** Start spooling a job - return the jobid. ***************************************************************************/ @@ -1736,6 +1905,9 @@ to open spool file %s.\n", pjob.filename)); pjob_store(snum, jobid, &pjob); + /* Update the 'jobs changed' entry used by print_queue_status. */ + add_to_jobs_changed(pdb, jobid); + /* Ensure we keep a rough count of the number of total jobs... */ tdb_change_int32_atomic(pdb->tdb, "INFO/total_jobs", &njobs, 1); @@ -1826,6 +1998,7 @@ BOOL print_job_end(int snum, uint32 jobid, BOOL normal_close) pjob->spooled = True; pjob->status = LPQ_QUEUED; pjob_store(snum, jobid, pjob); + remove_from_jobs_changed(snum, jobid); /* make sure the database is up to date */ if (print_cache_expired(snum)) @@ -1839,109 +2012,116 @@ fail: /* Still need to add proper error return propagation! 010122:JRR */ unlink(pjob->filename); pjob_delete(snum, jobid); + remove_from_jobs_changed(snum, jobid); return False; } /**************************************************************************** - Utility fn to enumerate the print queue. + Get a snapshot of jobs in the system without traversing. ****************************************************************************/ -static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void *state) +static BOOL get_stored_queue_info(struct tdb_print_db *pdb, int snum, int *pcount, print_queue_struct **ppqueue) { - struct traverse_struct *ts = (struct traverse_struct *)state; - struct printjob pjob; - int i; - uint32 jobid; - - /* sanity checks */ - - if ( key.dsize != sizeof(jobid) ) - return 0; - - memcpy(&jobid, key.dptr, sizeof(jobid)); - - if ( unpack_pjob( data.dptr, data.dsize, &pjob ) == -1 ) - return 0; - free_nt_devicemode( &pjob.nt_devmode ); - - /* maybe it isn't for this queue */ - if (ts->snum != lp_servicenumber(pjob.queuename)) - return 0; + TDB_DATA data, key, cgdata; + print_queue_struct *queue = NULL; + uint32 qcount = 0; + uint32 extra_count = 0; + int total_count = 0; + uint32 i; + int max_reported_jobs = lp_max_reported_jobs(snum); + BOOL ret = False; - if (ts->qcount >= ts->maxcount) - return 0; + *pcount = 0; + *ppqueue = NULL; - i = ts->qcount; + ZERO_STRUCT(data); + ZERO_STRUCT(cgdata); + key.dptr = "INFO/linear_queue_array"; + key.dsize = strlen(key.dptr); - ts->queue[i].job = jobid; - ts->queue[i].size = pjob.size; - ts->queue[i].page_count = pjob.page_count; - ts->queue[i].status = pjob.status; - ts->queue[i].priority = 1; - ts->queue[i].time = pjob.starttime; - fstrcpy(ts->queue[i].fs_user, pjob.user); - fstrcpy(ts->queue[i].fs_file, pjob.jobname); + /* Get the stored queue data. */ + data = tdb_fetch(pdb->tdb, key); - ts->qcount++; + if (data.dptr == NULL || data.dsize < 4) + qcount = 0; + else + memcpy(&qcount, data.dptr, 4); - return 0; -} + /* Get the changed jobs list. */ + key.dptr = "INFO/jobs_changed"; + key.dsize = strlen(key.dptr); -struct traverse_count_struct { - int snum, count; -}; + cgdata = tdb_fetch(pdb->tdb, key); + if (cgdata.dptr != NULL && (cgdata.dsize % 4 == 0)) + extra_count = cgdata.dsize/4; -/**************************************************************************** - Utility fn to count the number of entries in the print queue. -****************************************************************************/ + /* Allocate the queue size. */ + if (qcount == 0 && extra_count == 0) + goto out; + + if ((queue = (print_queue_struct *)malloc(sizeof(print_queue_struct)*(qcount + extra_count))) == NULL) + goto out; + + /* Retrieve the linearised queue data. */ + for( i = 0; i < qcount; i++) { + size_t len = 0; + uint32 qjob, qsize, qpage_count, qstatus, qpriority, qtime; + len += tdb_unpack(data.dptr + 4 + len, data.dsize - len, NULL, "ddddddff", + &qjob, + &qsize, + &qpage_count, + &qstatus, + &qpriority, + &qtime, + queue[i].fs_user, + queue[i].fs_file); + queue[i].job = qjob; + queue[i].size = qsize; + queue[i].page_count = qpage_count; + queue[i].status = qstatus; + queue[i].priority = qpriority; + queue[i].time = qtime; + } + + total_count = qcount; + + /* Add in the changed jobids. */ + for( i = 0; i < extra_count; i++) { + uint32 jobid; + struct printjob *pjob; + + memcpy(&jobid, &cgdata.dptr[i*4], 4); + pjob = print_job_find(snum, jobid); + if (!pjob) + continue; -static int traverse_count_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void *state) -{ - struct traverse_count_struct *ts = (struct traverse_count_struct *)state; - struct printjob pjob; - uint32 jobid; + queue[total_count].job = jobid; + queue[total_count].size = pjob->size; + queue[total_count].page_count = pjob->page_count; + queue[total_count].status = pjob->status; + queue[total_count].priority = 1; + fstrcpy(queue[total_count].fs_user, pjob->user); + fstrcpy(queue[total_count].fs_file, pjob->jobname); + } - /* sanity checks */ - - if ( key.dsize != sizeof(jobid) ) - return 0; - - memcpy(&jobid, key.dptr, sizeof(jobid)); - - if ( unpack_pjob( data.dptr, data.dsize, &pjob ) == -1 ) - return 0; - - free_nt_devicemode( &pjob.nt_devmode ); + /* Sort the queue by submission time otherwise they are displayed + in hash order. */ - /* maybe it isn't for this queue - this cannot happen with the tdb/printer code. JRA */ - if (ts->snum != lp_servicenumber(pjob.queuename)) - return 0; + qsort(queue, total_count, sizeof(print_queue_struct), QSORT_CAST(printjob_comp)); - ts->count++; + if (max_reported_jobs && total_count > max_reported_jobs) + total_count = max_reported_jobs; - return 0; -} + *ppqueue = queue; + *pcount = total_count; -/**************************************************************************** - Sort print jobs by submittal time. -****************************************************************************/ - -static int printjob_comp(print_queue_struct *j1, print_queue_struct *j2) -{ - /* Silly cases */ - - if (!j1 && !j2) - return 0; - if (!j1) - return -1; - if (!j2) - return 1; + ret = True; - /* Sort on job start time */ + out: - if (j1->time == j2->time) - return 0; - return (j1->time > j2->time) ? 1 : -1; + SAFE_FREE(data.dptr); + SAFE_FREE(cgdata.dptr); + return ret; } /**************************************************************************** @@ -1950,16 +2130,14 @@ static int printjob_comp(print_queue_struct *j1, print_queue_struct *j2) ****************************************************************************/ int print_queue_status(int snum, - print_queue_struct **queue, + print_queue_struct **ppqueue, print_status_struct *status) { - struct traverse_struct tstruct; - struct traverse_count_struct tsc; fstring keystr; TDB_DATA data, key; const char *printername; struct tdb_print_db *pdb; - int max_reported_jobs = lp_max_reported_jobs(snum); + int count = 0; /* make sure the database is up to date */ @@ -1967,11 +2145,10 @@ int print_queue_status(int snum, print_queue_update(snum); /* return if we are done */ - - if ( !queue || !status ) + if ( !ppqueue || !status ) return 0; - *queue = NULL; + *ppqueue = NULL; printername = lp_const_servicename(snum); pdb = get_print_db_byname(printername); @@ -1982,6 +2159,7 @@ int print_queue_status(int snum, * Fetch the queue status. We must do this first, as there may * be no jobs in the queue. */ + ZERO_STRUCTP(status); slprintf(keystr, sizeof(keystr)-1, "STATUS/%s", printername); key.dptr = keystr; @@ -1998,47 +2176,14 @@ int print_queue_status(int snum, * Now, fetch the print queue information. We first count the number * of entries, and then only retrieve the queue if necessary. */ - tsc.count = 0; - tsc.snum = snum; - - tdb_traverse(pdb->tdb, traverse_count_fn_queue, (void *)&tsc); - if (tsc.count == 0) { + if (!get_stored_queue_info(pdb, snum, &count, ppqueue)) { release_print_db(pdb); return 0; } - /* Allocate the queue size. */ - if ((tstruct.queue = (print_queue_struct *) - malloc(sizeof(print_queue_struct)*tsc.count)) == NULL) { - release_print_db(pdb); - return 0; - } - - /* - * Fill in the queue. - * We need maxcount as the queue size may have changed between - * the two calls to tdb_traverse. - */ - tstruct.qcount = 0; - tstruct.maxcount = tsc.count; - tstruct.snum = snum; - - tdb_traverse(pdb->tdb, traverse_fn_queue, (void *)&tstruct); release_print_db(pdb); - - /* Sort the queue by submission time otherwise they are displayed - in hash order. */ - - qsort(tstruct.queue, tstruct.qcount, sizeof(print_queue_struct), - QSORT_CAST(printjob_comp)); - - *queue = tstruct.queue; - - if (max_reported_jobs && tstruct.qcount > max_reported_jobs) - tstruct.qcount = max_reported_jobs; - - return tstruct.qcount; + return count; } /**************************************************************************** -- cgit From ab25a258c0c5486e513f0ab5e04c1923e9355a26 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 21 Mar 2003 22:31:25 +0000 Subject: Patch from colo (on IRC) to get libsmbclient building due to pstring/fstring issues. Also pick up these link failures at compile time (rather than runtime). Andrew Bartlett (This used to be commit 23c7342bc40daffbcd70ef04727cae2c2b2c366b) --- source3/configure.in | 2 +- source3/libsmb/libsmbclient.c | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index b6fabe6085..5d7a65f620 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -914,7 +914,7 @@ if test "$enable_shared" = "yes"; then case "$host_os" in *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) BLDSHARED="true" - LDSHFLAGS="-shared" + LDSHFLAGS="-shared -Wl,-no-undefined" DYNEXP="-Wl,--export-dynamic" PICFLAG="-fPIC" SONAMEFLAG="-Wl,-soname=" diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c index 5ceb36795a..440527cd9d 100644 --- a/source3/libsmb/libsmbclient.c +++ b/source3/libsmb/libsmbclient.c @@ -492,9 +492,9 @@ static SMBCFILE *smbc_open_ctx(SMBCCTX *context, const char *fname, int flags, m smbc_parse_path(context, fname, server, share, path, user, password); /* FIXME, check errors */ - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); srv = smbc_server(context, server, share, workgroup, user, password); @@ -821,9 +821,9 @@ static int smbc_unlink_ctx(SMBCCTX *context, const char *fname) smbc_parse_path(context, fname, server, share, path, user, password); /* FIXME, check errors */ - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); srv = smbc_server(context, server, share, workgroup, user, password); @@ -920,11 +920,11 @@ static int smbc_rename_ctx(SMBCCTX *ocontext, const char *oname, smbc_parse_path(ocontext, oname, server1, share1, path1, user1, password1); - if (user1[0] == (char)0) pstrcpy(user1, ocontext->user); + if (user1[0] == (char)0) fstrcpy(user1, ocontext->user); smbc_parse_path(ncontext, nname, server2, share2, path2, user2, password2); - if (user2[0] == (char)0) pstrcpy(user2, ncontext->user); + if (user2[0] == (char)0) fstrcpy(user2, ncontext->user); if (strcmp(server1, server2) || strcmp(share1, share2) || strcmp(user1, user2)) { @@ -936,7 +936,7 @@ static int smbc_rename_ctx(SMBCCTX *ocontext, const char *oname, } - pstrcpy(workgroup, ocontext->workgroup); + fstrcpy(workgroup, ocontext->workgroup); /* HELP !!! Which workgroup should I use ? Or are they always the same -- Tom */ srv = smbc_server(ocontext, server1, share1, workgroup, user1, password1); if (!srv) { @@ -1119,9 +1119,9 @@ static int smbc_stat_ctx(SMBCCTX *context, const char *fname, struct stat *st) smbc_parse_path(context, fname, server, share, path, user, password); /*FIXME, errors*/ - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); srv = smbc_server(context, server, share, workgroup, user, password); @@ -1422,9 +1422,9 @@ static SMBCFILE *smbc_opendir_ctx(SMBCCTX *context, const char *fname) } - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); dir = malloc(sizeof(*dir)); @@ -1893,9 +1893,9 @@ static int smbc_mkdir_ctx(SMBCCTX *context, const char *fname, mode_t mode) smbc_parse_path(context, fname, server, share, path, user, password); /*FIXME, errors*/ - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); srv = smbc_server(context, server, share, workgroup, user, password); @@ -1980,9 +1980,9 @@ static int smbc_rmdir_ctx(SMBCCTX *context, const char *fname) smbc_parse_path(context, fname, server, share, path, user, password); /*FIXME, errors*/ - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); srv = smbc_server(context, server, share, workgroup, user, password); @@ -2327,9 +2327,9 @@ static int smbc_list_print_jobs_ctx(SMBCCTX *context, const char *fname, smbc_li smbc_parse_path(context, fname, server, share, path, user, password); /*FIXME, errors*/ - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); srv = smbc_server(context, server, share, workgroup, user, password); @@ -2380,9 +2380,9 @@ static int smbc_unlink_print_job_ctx(SMBCCTX *context, const char *fname, int id smbc_parse_path(context, fname, server, share, path, user, password); /*FIXME, errors*/ - if (user[0] == (char)0) pstrcpy(user, context->user); + if (user[0] == (char)0) fstrcpy(user, context->user); - pstrcpy(workgroup, context->workgroup); + fstrcpy(workgroup, context->workgroup); srv = smbc_server(context, server, share, workgroup, user, password); -- cgit From d2d29ea9530a5d7077cf0ee138f1f29095e5b496 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 21 Mar 2003 22:37:14 +0000 Subject: Clobber our SMB buffers between packets. I hope this will help find bugs where we assume the buffer is zero, when it might not be (ie due to, previous packets). Andrew Bartlett (This used to be commit 191b0ab4d7c35c83d2bb2052b2e37d01fbf37b45) --- source3/smbd/process.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 57bc236eef..c3fbc22e94 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1249,12 +1249,16 @@ void smbd_process(void) extern int smb_echo_count; time_t last_timeout_processing_time = time(NULL); unsigned int num_smbs = 0; + const size_t total_buffer_size = BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE + SAFETY_MARGIN; - InBuffer = (char *)malloc(BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE + SAFETY_MARGIN); - OutBuffer = (char *)malloc(BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE + SAFETY_MARGIN); + InBuffer = (char *)malloc(total_buffer_size); + OutBuffer = (char *)malloc(total_buffer_size); if ((InBuffer == NULL) || (OutBuffer == NULL)) return; + clobber_region(__FUNCTION__, __LINE__, InBuffer, total_buffer_size); + clobber_region(__FUNCTION__, __LINE__, OutBuffer, total_buffer_size); + max_recv = MIN(lp_maxxmit(),BUFFER_SIZE); while (True) { @@ -1278,6 +1282,8 @@ void smbd_process(void) num_smbs = 0; /* Reset smb counter. */ } + clobber_region(__FUNCTION__, __LINE__, InBuffer, total_buffer_size); + while (!receive_message_or_smb(InBuffer,BUFFER_SIZE+LARGE_WRITEX_HDR_SIZE,select_timeout)) { if(!timeout_processing( deadtime, &select_timeout, &last_timeout_processing_time)) return; @@ -1295,6 +1301,8 @@ void smbd_process(void) */ num_echos = smb_echo_count; + clobber_region(__FUNCTION__, __LINE__, OutBuffer, total_buffer_size); + process_smb(InBuffer, OutBuffer); if (smb_echo_count != num_echos) { -- cgit From 2da9a44ba014f74835aea95d50de8ab043d2b6c5 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 21 Mar 2003 22:38:04 +0000 Subject: Clobber the 'SAFETY_MARGIN' in libsmb. Andrew Bartlett (This used to be commit 05a63bd17e4c35979b3864b0969b2bfd945335d9) --- source3/libsmb/clientgen.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index d969193089..e067e92f8d 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -259,9 +259,6 @@ struct cli_state *cli_initialise(struct cli_state *cli) if (getenv("CLI_FORCE_DOSERR")) cli->force_dos_errors = True; - /* initialise signing */ - cli_null_set_signing(cli); - if (lp_client_signing()) cli->sign_info.allow_smb_signing = True; @@ -274,6 +271,13 @@ struct cli_state *cli_initialise(struct cli_state *cli) memset(cli->outbuf, 0, cli->bufsize); memset(cli->inbuf, 0, cli->bufsize); + /* just becouse we over-allocate, doesn't mean it's right to use it */ + clobber_region(__FUNCTION__, __LINE__, cli->outbuf+cli->bufsize, SAFETY_MARGIN); + clobber_region(__FUNCTION__, __LINE__, cli->inbuf+cli->bufsize, SAFETY_MARGIN); + + /* initialise signing */ + cli_null_set_signing(cli); + cli->nt_pipe_fnum = 0; cli->initialised = 1; -- cgit From 58cd54aeb8320e28b348ab7045fd348561c0a5c2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 00:27:18 +0000 Subject: FALSE -> False (reported by Paul Green) (This used to be commit 1002b0bbff295548b74580dbb0dc0c76474af23b) --- source3/passdb/pdb_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index b146951561..4d9ec7beea 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -28,7 +28,7 @@ static struct pdb_init_function_entry *backends = NULL; static void lazy_initialize_passdb(void) { - static BOOL initialized = FALSE; + static BOOL initialized = False; if(initialized)return; static_init_pdb; initialized = True; -- cgit From 87cbd9ab68ed5f0831440009b16915edc7473e49 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 08:07:53 +0000 Subject: Patch from Jianliang Lu to set the 'minimum password age' when setting the password. Andrew Bartlett (This used to be commit 552198b9e149c41f8cb2f976421ef030eac6fba6) --- source3/passdb/pdb_get_set.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source3') diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c index 2efe720474..a86d936263 100644 --- a/source3/passdb/pdb_get_set.c +++ b/source3/passdb/pdb_get_set.c @@ -1064,6 +1064,7 @@ BOOL pdb_set_hours (SAM_ACCOUNT *sampass, const uint8 *hours, enum pdb_value_sta BOOL pdb_set_pass_changed_now (SAM_ACCOUNT *sampass) { uint32 expire; + uint32 min_age; if (!sampass) return False; @@ -1082,6 +1083,16 @@ BOOL pdb_set_pass_changed_now (SAM_ACCOUNT *sampass) return False; } + if (!account_policy_get(AP_MIN_PASSWORD_AGE, &min_age) + || (min_age==(uint32)-1)) { + if (!pdb_set_pass_can_change_time (sampass, 0, PDB_CHANGED)) + return False; + } else { + if (!pdb_set_pass_can_change_time (sampass, + pdb_get_pass_last_set_time(sampass) + + min_age, PDB_CHANGED)) + return False; + } return True; } -- cgit From bde949c721248c27385a5ea6c7813c7c45271ff0 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 10:44:07 +0000 Subject: It seems that this causes some problems on some linux platforms - it's a pity becouse otherwise you need to link a program with it to get the fstring/pstring bugs. Andrew Bartlett (This used to be commit b1b4370955d50fd4997c7171a99fe03f97190aca) --- source3/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 5d7a65f620..b6fabe6085 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -914,7 +914,7 @@ if test "$enable_shared" = "yes"; then case "$host_os" in *linux*) AC_DEFINE(LINUX,1,[Whether the host os is linux]) BLDSHARED="true" - LDSHFLAGS="-shared -Wl,-no-undefined" + LDSHFLAGS="-shared" DYNEXP="-Wl,--export-dynamic" PICFLAG="-fPIC" SONAMEFLAG="-Wl,-soname=" -- cgit From b508fdfc231b73d671b0c283e54532b9f14d7db6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 10:54:03 +0000 Subject: Fix compile on IA64 by noting that this should be the integer, not a pointer to the integer for SIVAL(). (This used to be commit e8b4b136669e7e415557956d698c66c254b28ec1) --- source3/libsmb/ntlmssp_sign.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/ntlmssp_sign.c b/source3/libsmb/ntlmssp_sign.c index f51d532319..8f6bd0c691 100644 --- a/source3/libsmb/ntlmssp_sign.c +++ b/source3/libsmb/ntlmssp_sign.c @@ -100,7 +100,7 @@ static NTSTATUS ntlmssp_make_packet_signiture(NTLMSSP_CLIENT_STATE *ntlmssp_stat HMACMD5Context ctx; char seq_num[4]; uchar digest[16]; - SIVAL(seq_num, 0, &ntlmssp_state->ntlmssp_seq_num); + SIVAL(seq_num, 0, ntlmssp_state->ntlmssp_seq_num); hmac_md5_init_limK_to_64(ntlmssp_state->cli_sign_const, 16, &ctx); hmac_md5_update(seq_num, 4, &ctx); -- cgit From a38e5e6850220fc1a0afa5097359c05458e1ae41 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 13:06:52 +0000 Subject: Small clenaup patches: - safe_string.h - don't assume that __FUNCTION__ is available - process.c - use new workaround from safe_string.h for the same - util.c - Show how many bytes we smb_panic()ed trying to smb_xmalloc() - gencache.c - Keep valgrind quiet by always null terminating. - clistr.c - Add copyright - srvstr.h - move srvstr_push into a .c file again, as a real function. - srvstr.c - revive, with 'safe' checked srvstr_push - loadparm.c - set a default for the display charset. Andrew Bartlett (This used to be commit a7eba37aadeb0b04cb1bd89deddb58be8aba825c) --- source3/Makefile.in | 2 +- source3/include/safe_string.h | 50 +++++++++++++++++++++---------------------- source3/include/srvstr.h | 3 --- source3/lib/gencache.c | 12 +++++------ source3/lib/util.c | 4 +++- source3/libsmb/clistr.c | 3 ++- source3/param/loadparm.c | 3 +++ source3/smbd/connection.c | 23 +++++++++----------- source3/smbd/process.c | 8 +++---- source3/smbd/srvstr.c | 44 +++++++++++++++++++++++++++++++++++++ 10 files changed, 98 insertions(+), 54 deletions(-) create mode 100644 source3/smbd/srvstr.c (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 8a40525084..c4bdbe3b11 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -306,7 +306,7 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \ smbd/message.o smbd/nttrans.o smbd/pipes.o \ smbd/reply.o smbd/sesssetup.o smbd/trans2.o smbd/uid.o \ smbd/dosmode.o smbd/filename.o smbd/open.o smbd/close.o \ - smbd/blocking.o smbd/sec_ctx.o \ + smbd/blocking.o smbd/sec_ctx.o smbd/srvstr.o \ smbd/vfs.o smbd/vfs-wrap.o smbd/statcache.o \ smbd/posix_acls.o lib/sysacls.o lib/server_mutex.o \ smbd/process.o smbd/service.o smbd/error.o \ diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h index 61ef4bdf96..f26a5785cb 100644 --- a/source3/include/safe_string.h +++ b/source3/include/safe_string.h @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. Safe string handling routines. Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) Andrew Bartlett 2003 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 @@ -48,6 +49,14 @@ #endif /* !_SPLINT_ */ +#ifdef DEVELOPER +#define SAFE_STRING_FUNCTION_NAME FUNCTION_MACRO +#define SAFE_STRING_LINE __LINE__ +#else +#define SAFE_STRING_FUNCTION_NAME ("") +#define SAFE_STRING_LINE (0) +#endif + /* We need a number of different prototypes for our non-existant fuctions */ char * __unsafe_string_function_usage_here__(void); @@ -141,32 +150,17 @@ size_t __unsafe_string_function_usage_here_char__(void); * long. This is not a good situation, because we can't do the normal * sanity checks. Don't use in new code! */ -#ifdef DEVELOPER -#define overmalloc_safe_strcpy(dest,src,maxlength) safe_strcpy_fn(__FUNCTION__,__LINE__,dest,src,maxlength) -#define safe_strcpy(dest,src,maxlength) safe_strcpy_fn2(__FUNCTION__,__LINE__,dest,src,maxlength) -#define safe_strcat(dest,src,maxlength) safe_strcat_fn2(__FUNCTION__,__LINE__,dest,src,maxlength) -#define push_string(base_ptr, dest, src, dest_len, flags) push_string_fn2(__FUNCTION__, __LINE__, base_ptr, dest, src, dest_len, flags) -#define pull_string(base_ptr, dest, src, dest_len, src_len, flags) pull_string_fn2(__FUNCTION__, __LINE__, base_ptr, dest, src, dest_len, src_len, flags) -#define clistr_push(cli, dest, src, dest_len, flags) clistr_push_fn2(__FUNCTION__, __LINE__, cli, dest, src, dest_len, flags) -#define clistr_pull(cli, dest, src, dest_len, src_len, flags) clistr_pull_fn2(__FUNCTION__, __LINE__, cli, dest, src, dest_len, src_len, flags) - -#define alpha_strcpy(dest,src,other_safe_chars,maxlength) alpha_strcpy_fn(__FUNCTION__,__LINE__,dest,src,other_safe_chars,maxlength) -#define StrnCpy(dest,src,n) StrnCpy_fn(__FUNCTION__,__LINE__,dest,src,n) - -#else - -#define overmalloc_safe_strcpy(dest,src,maxlength) safe_strcpy_fn(NULL,0,dest,src,maxlength) -#define safe_strcpy(dest,src,maxlength) safe_strcpy_fn2(NULL,0,dest,src,maxlength) -#define safe_strcat(dest,src,maxlength) safe_strcat_fn2(NULL,0,dest,src,maxlength) -#define push_string(base_ptr, dest, src, dest_len, flags) push_string_fn2(NULL, 0, base_ptr, dest, src, dest_len, flags) -#define pull_string(base_ptr, dest, src, dest_len, src_len, flags) pull_string_fn2(NULL, 0, base_ptr, dest, src, dest_len, src_len, flags) -#define clistr_push(cli, dest, src, dest_len, flags) clistr_push_fn2(NULL, 0, cli, dest, src, dest_len, flags) -#define clistr_pull(cli, dest, src, dest_len, src_len, flags) clistr_pull_fn2(NULL, 0, cli, dest, src, dest_len, src_len, flags) - -#define alpha_strcpy(dest,src,other_safe_chars,maxlength) alpha_strcpy_fn(NULL,0,dest,src,other_safe_chars,maxlength) -#define StrnCpy(dest,src,n) StrnCpy_fn(NULL,0,dest,src,n) -#endif /* DEVELOPER */ +#define overmalloc_safe_strcpy(dest,src,maxlength) safe_strcpy_fn(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE,dest,src,maxlength) +#define safe_strcpy(dest,src,maxlength) safe_strcpy_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE,dest,src,maxlength) +#define safe_strcat(dest,src,maxlength) safe_strcat_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE,dest,src,maxlength) +#define push_string(base_ptr, dest, src, dest_len, flags) push_string_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, base_ptr, dest, src, dest_len, flags) +#define pull_string(base_ptr, dest, src, dest_len, src_len, flags) pull_string_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, base_ptr, dest, src, dest_len, src_len, flags) +#define clistr_push(cli, dest, src, dest_len, flags) clistr_push_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, cli, dest, src, dest_len, flags) +#define clistr_pull(cli, dest, src, dest_len, src_len, flags) clistr_pull_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, cli, dest, src, dest_len, src_len, flags) +#define srvstr_push(base_ptr, dest, src, dest_len, flags) srvstr_push_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, base_ptr, dest, src, dest_len, flags) +#define alpha_strcpy(dest,src,other_safe_chars,maxlength) alpha_strcpy_fn(SAFE_STRING_FUNCTION_NAME,SAFE_STRING_LINE,dest,src,other_safe_chars,maxlength) +#define StrnCpy(dest,src,n) StrnCpy_fn(SAFE_STRING_FUNCTION_NAME,SAFE_STRING_LINE,dest,src,n) #ifdef HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS @@ -204,6 +198,11 @@ size_t __unsafe_string_function_usage_here_char__(void); ? __unsafe_string_function_usage_here_size_t__() \ : clistr_pull_fn(fn_name, fn_line, cli, dest, src, dest_len, srclen, flags)) +#define srvstr_push_fn2(fn_name, fn_line, base_ptr, dest, src, dest_len, flags) \ + (CHECK_STRING_SIZE(dest, dest_len) \ + ? __unsafe_string_function_usage_here_size_t__() \ + : srvstr_push_fn(fn_name, fn_line, base_ptr, dest, src, dest_len, flags)) + #else #define safe_strcpy_fn2 safe_strcpy_fn @@ -212,6 +211,7 @@ size_t __unsafe_string_function_usage_here_char__(void); #define pull_string_fn2 pull_string_fn #define clistr_push_fn2 clistr_push_fn #define clistr_pull_fn2 clistr_pull_fn +#define srvstr_push_fn2 srvstr_push_fn #endif diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h index a433e0e3f9..04db59cf01 100644 --- a/source3/include/srvstr.h +++ b/source3/include/srvstr.h @@ -20,9 +20,6 @@ #include "includes.h" -#define srvstr_push(base_ptr, dest, src, dest_len, flags) \ - push_string(base_ptr, dest, src, dest_len, flags) - #define srvstr_pull(base_ptr, dest, src, dest_len, src_len, flags) \ pull_string(base_ptr, dest, src, dest_len, src_len, flags) diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index 5c8ad1339b..eb0e0cd808 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -115,9 +115,9 @@ BOOL gencache_set(const char *keystr, const char *value, time_t timeout) asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value); keybuf.dptr = strdup(keystr); - keybuf.dsize = strlen(keystr); + keybuf.dsize = strlen(keystr)+1; databuf.dptr = strdup(valstr); - databuf.dsize = strlen(valstr); + databuf.dsize = strlen(valstr)+1; DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout \ = %s (%d seconds %s)\n", keybuf.dptr, value, ctime(&timeout), (int)(timeout - time(NULL)), timeout > time(NULL) ? "ahead" : "in the past")); @@ -167,9 +167,9 @@ BOOL gencache_set_only(const char *keystr, const char *valstr, time_t timeout) asprintf(&datastr, CACHE_DATA_FMT, (int)timeout, valstr); keybuf.dptr = strdup(keystr); - keybuf.dsize = strlen(keystr); + keybuf.dsize = strlen(keystr)+1; databuf.dptr = strdup(datastr); - databuf.dsize = strlen(datastr); + databuf.dsize = strlen(datastr)+1; DEBUGADD(10, ("New value = %s, new timeout = %s (%d seconds %s)", valstr, ctime(&timeout), (int)(timeout - time(NULL)), timeout > time(NULL) ? "ahead" : "in the past")); @@ -206,7 +206,7 @@ BOOL gencache_del(const char *keystr) if (!gencache_init()) return False; keybuf.dptr = strdup(keystr); - keybuf.dsize = strlen(keystr); + keybuf.dsize = strlen(keystr)+1; DEBUG(10, ("Deleting cache entry (key = %s)\n", keystr)); ret = tdb_delete(cache, keybuf); @@ -239,7 +239,7 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout) return False; keybuf.dptr = strdup(keystr); - keybuf.dsize = strlen(keystr); + keybuf.dsize = strlen(keystr)+1; databuf = tdb_fetch(cache, keybuf); if (databuf.dptr && databuf.dsize > TIMEOUT_LEN) { diff --git a/source3/lib/util.c b/source3/lib/util.c index 4216310335..4f564b332a 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -2089,8 +2089,10 @@ void *smb_xmalloc(size_t size) void *p; if (size == 0) smb_panic("smb_xmalloc: called with zero size.\n"); - if ((p = malloc(size)) == NULL) + if ((p = malloc(size)) == NULL) { + DEBUG(0, ("smb_xmalloc() failed to allocate %lu bytes\n", (unsigned long)size)); smb_panic("smb_xmalloc: malloc fail.\n"); + } return p; } diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c index 97a3fa6cc9..c61445c073 100644 --- a/source3/libsmb/clistr.c +++ b/source3/libsmb/clistr.c @@ -2,7 +2,8 @@ Unix SMB/CIFS implementation. client string routines Copyright (C) Andrew Tridgell 2001 - + Copyright (C) Andrew Bartlett 2003 + 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 the Free Software Foundation; either version 2 of the License, or diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 6baaafbd9c..f8a1990513 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1285,6 +1285,9 @@ static void init_globals(void) /* using UTF8 by default allows us to support all chars */ string_set(&Globals.unix_charset, "UTF8"); + /* using UTF8 by default allows us to support all chars */ + string_set(&Globals.display_charset, "ASCII"); + /* Use codepage 850 as a default for the dos character set */ string_set(&Globals.dos_charset, "CP850"); diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index a7636e889e..ff6974cade 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -35,15 +35,12 @@ TDB_CONTEXT *conn_tdb_ctx(void) return tdb; } -static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, struct connections_key *pkey) +static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, fstring tdb_key) { - ZERO_STRUCTP(pkey); - pkey->pid = sys_getpid(); - pkey->cnum = conn?conn->cnum:-1; - fstrcpy(pkey->name, name); + snprintf(tdb_key, sizeof(fstring), "CONN/%lu/%ld", sys_getpid(), conn?conn->cnum:-1); - pkbuf->dptr = (char *)pkey; - pkbuf->dsize = sizeof(*pkey); + pkbuf->dptr = tdb_key; + pkbuf->dsize = strlen(tdb_key)+1; } /**************************************************************************** @@ -52,7 +49,7 @@ static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *p BOOL yield_connection(connection_struct *conn, const char *name) { - struct connections_key key; + fstring tdb_key; TDB_DATA kbuf; if (!tdb) @@ -60,7 +57,7 @@ BOOL yield_connection(connection_struct *conn, const char *name) DEBUG(3,("Yielding connection to %s\n",name)); - make_conn_key(conn, name, &kbuf, &key); + make_conn_key(conn, name, &kbuf, tdb_key); if (tdb_delete(tdb, kbuf) != 0) { int dbg_lvl = (!conn && (tdb_error(tdb) == TDB_ERR_NOEXIST)) ? 3 : 0; @@ -171,14 +168,14 @@ BOOL claim_connection(connection_struct *conn, const char *name,int max_connecti if (conn) { crec.uid = conn->uid; crec.gid = conn->gid; - StrnCpy(crec.name, - lp_servicename(SNUM(conn)),sizeof(crec.name)-1); + safe_strcpy(crec.name, + lp_servicename(SNUM(conn)),sizeof(crec.name)-1); } crec.start = time(NULL); crec.bcast_msg_flags = msg_flags; - StrnCpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1); - StrnCpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1); + safe_strcpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1); + safe_strcpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1); dbuf.dptr = (char *)&crec; dbuf.dsize = sizeof(crec); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index c3fbc22e94..16ef30c46c 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1256,8 +1256,8 @@ void smbd_process(void) if ((InBuffer == NULL) || (OutBuffer == NULL)) return; - clobber_region(__FUNCTION__, __LINE__, InBuffer, total_buffer_size); - clobber_region(__FUNCTION__, __LINE__, OutBuffer, total_buffer_size); + clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, InBuffer, total_buffer_size); + clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, OutBuffer, total_buffer_size); max_recv = MIN(lp_maxxmit(),BUFFER_SIZE); @@ -1282,7 +1282,7 @@ void smbd_process(void) num_smbs = 0; /* Reset smb counter. */ } - clobber_region(__FUNCTION__, __LINE__, InBuffer, total_buffer_size); + clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, InBuffer, total_buffer_size); while (!receive_message_or_smb(InBuffer,BUFFER_SIZE+LARGE_WRITEX_HDR_SIZE,select_timeout)) { if(!timeout_processing( deadtime, &select_timeout, &last_timeout_processing_time)) @@ -1301,7 +1301,7 @@ void smbd_process(void) */ num_echos = smb_echo_count; - clobber_region(__FUNCTION__, __LINE__, OutBuffer, total_buffer_size); + clobber_region(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, OutBuffer, total_buffer_size); process_smb(InBuffer, OutBuffer); diff --git a/source3/smbd/srvstr.c b/source3/smbd/srvstr.c new file mode 100644 index 0000000000..409fd30a67 --- /dev/null +++ b/source3/smbd/srvstr.c @@ -0,0 +1,44 @@ +/* + Unix SMB/CIFS implementation. + server specific string routines + Copyright (C) Andrew Tridgell 2001 + Copyright (C) Andrew Bartlett 2003 + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +extern int max_send; + +/* Make sure we can't write a string past the end of the buffer */ + +size_t srvstr_push_fn(const char *function, unsigned int line, + const char *base_ptr, void *dest, + const char *src, int dest_len, int flags) +{ + size_t buf_used = PTR_DIFF(dest, base_ptr); + if (dest_len == -1) { + if (((ptrdiff_t)dest < (ptrdiff_t)base_ptr) || (buf_used > (size_t)max_send)) { +#if 0 + DEBUG(0, ("Pushing string of 'unlimited' length into non-SMB buffer!\n")); +#endif + return push_string_fn(function, line, base_ptr, dest, src, -1, flags); + } + return push_string_fn(function, line, base_ptr, dest, src, max_send - buf_used, flags); + } + + /* 'normal' push into size-specified buffer */ + return push_string_fn(function, line, base_ptr, dest, src, dest_len, flags); +} -- cgit From 5050e8ee1a1fd3280d65d22c079ac90cf7e454e9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 13:41:16 +0000 Subject: Revert bogus part of previous patch. (This used to be commit 3cddfe211da812a533611eecba5d5da55fd3cf2d) --- source3/smbd/connection.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index ff6974cade..5547309a81 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -35,12 +35,15 @@ TDB_CONTEXT *conn_tdb_ctx(void) return tdb; } -static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, fstring tdb_key) +static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, struct connections_key *pkey) { - snprintf(tdb_key, sizeof(fstring), "CONN/%lu/%ld", sys_getpid(), conn?conn->cnum:-1); + ZERO_STRUCTP(pkey); + pkey->pid = sys_getpid(); + pkey->cnum = conn?conn->cnum:-1; + fstrcpy(pkey->name, name); - pkbuf->dptr = tdb_key; - pkbuf->dsize = strlen(tdb_key)+1; + pkbuf->dptr = (char *)pkey; + pkbuf->dsize = sizeof(*pkey); } /**************************************************************************** @@ -49,7 +52,7 @@ static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *p BOOL yield_connection(connection_struct *conn, const char *name) { - fstring tdb_key; + struct connections_key key; TDB_DATA kbuf; if (!tdb) @@ -57,7 +60,7 @@ BOOL yield_connection(connection_struct *conn, const char *name) DEBUG(3,("Yielding connection to %s\n",name)); - make_conn_key(conn, name, &kbuf, tdb_key); + make_conn_key(conn, name, &kbuf, &key); if (tdb_delete(tdb, kbuf) != 0) { int dbg_lvl = (!conn && (tdb_error(tdb) == TDB_ERR_NOEXIST)) ? 3 : 0; -- cgit From a9aa2cb025e382ac5801d78462cc6e017e41a438 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 22 Mar 2003 19:15:50 +0000 Subject: This changes the way we do LDAP updates. We don't use LDAP_MOD_MODIFY anymore, but instead look at what is currently stored in the database. Then we explicitly delete the existing attribute and add the new value if it is not NULL or "". This way we can handle appearing and disappearing attributes quite nicely. This currently breaks pdbedit -o, as this does not set the CHANGED flag on the SAM_ACCOUNT. Jelmer suggested that we set all the fields on CHANGED in context_add_sam_account. This sounds not too unreasonable. Volker (This used to be commit f7149cf500d2b10ee72163c018a39fdd192d7632) --- source3/passdb/pdb_ldap.c | 296 +++++++++++++++++++++++++++------------------- 1 file changed, 175 insertions(+), 121 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 375fbeacc5..7cb092a9bc 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -1158,8 +1158,10 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state, * that fits your needs; using cn then displayName rather than 'userFullName' */ - if (!get_single_attribute(ldap_state->ldap_struct, entry, "cn", fullname)) { - if (!get_single_attribute(ldap_state->ldap_struct, entry, "displayName", fullname)) { + if (!get_single_attribute(ldap_state->ldap_struct, entry, + "displayName", fullname)) { + if (!get_single_attribute(ldap_state->ldap_struct, entry, + "cn", fullname)) { /* leave as default */ } else { pdb_set_fullname(sampass, fullname, PDB_SET); @@ -1279,14 +1281,68 @@ static BOOL need_ldap_mod(BOOL pdb_add, const SAM_ACCOUNT * sampass, enum pdb_el } } +/********************************************************************** + Set attribute to newval in LDAP, regardless of what value the + attribute had in LDAP before. +*********************************************************************/ +static void make_ldap_mod(LDAP *ldap_struct, LDAPMessage *existing, + LDAPMod ***mods, + const SAM_ACCOUNT *sampass, + enum pdb_elements element, + const char *attribute, const char *newval) +{ + char **values = NULL; + + if (!IS_SAM_CHANGED(sampass, element)) { + return; + } + + if (existing != NULL) { + values = ldap_get_values(ldap_struct, existing, attribute); + } + + if ((values != NULL) && (values[0] != NULL) && + strcmp(values[0], newval) == 0) { + + /* Believe it or not, but LDAP will deny a delete and + an add at the same time if the values are the + same... */ + + ldap_value_free(values); + return; + } + + /* Regardless of the real operation (add or modify) + we add the new value here. We rely on deleting + the old value, should it exist. */ + + if ((newval != NULL) && (strlen(newval) > 0)) { + make_a_mod(mods, LDAP_MOD_ADD, attribute, newval); + } + + if (values == NULL) { + /* There has been no value before, so don't delete it. + Here's a possible race: We might end up with + duplicate attributes */ + return; + } + + /* By deleting exactly the value we found in the entry this + should be race-free in the sense that the LDAP-Server will + deny the complete operation if somebody changed the + attribute behind our back. */ + + make_a_mod(mods, LDAP_MOD_DELETE, attribute, values[0]); + ldap_value_free(values); +} + /********************************************************************** Initialize SAM_ACCOUNT from an LDAP query (Based on init_buffer_from_sam in pdb_tdb.c) *********************************************************************/ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, - LDAPMod *** mods, int ldap_op, - BOOL pdb_add, - const SAM_ACCOUNT * sampass) + LDAPMessage *existing, + LDAPMod *** mods, const SAM_ACCOUNT * sampass) { pstring temp; uint32 rid; @@ -1302,139 +1358,136 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, * took out adding "objectclass: sambaAccount" * do this on a per-mod basis */ - if (need_ldap_mod(pdb_add, sampass, PDB_USERNAME)) { - make_a_mod(mods, ldap_op, "uid", pdb_get_username(sampass)); - DEBUG(2, ("Setting entry for user: %s\n", pdb_get_username(sampass))); - } - - if ((rid = pdb_get_user_rid(sampass))!=0 ) { - if (need_ldap_mod(pdb_add, sampass, PDB_USERSID)) { - slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_a_mod(mods, ldap_op, "rid", temp); - } - } else if (!IS_SAM_DEFAULT(sampass, PDB_UID)) { + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_USERNAME, "uid", pdb_get_username(sampass)); + DEBUG(2, ("Setting entry for user: %s\n", pdb_get_username(sampass))); + + rid = pdb_get_user_rid(sampass); + + if ( (rid==0) && (!IS_SAM_DEFAULT(sampass, PDB_UID)) ) { rid = fallback_pdb_uid_to_user_rid(pdb_get_uid(sampass)); - slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_a_mod(mods, ldap_op, "rid", temp); } else if (ldap_state->permit_non_unix_accounts) { rid = ldapsam_get_next_available_nua_rid(ldap_state); if (rid == 0) { - DEBUG(0, ("NO user RID specified on account %s, and findining next available NUA RID failed, cannot store!\n", pdb_get_username(sampass))); + DEBUG(0, ("NO user RID specified on account %s, and " + "findining next available NUA RID failed, " + "cannot store!\n", + pdb_get_username(sampass))); + ldap_mods_free(*mods, 1); return False; } - slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_a_mod(mods, ldap_op, "rid", temp); } else { - DEBUG(0, ("NO user RID specified on account %s, cannot store!\n", pdb_get_username(sampass))); + DEBUG(0, ("NO user RID specified on account %s, " + "cannot store!\n", pdb_get_username(sampass))); + ldap_mods_free(*mods, 1); return False; } + slprintf(temp, sizeof(temp) - 1, "%i", rid); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_USERSID, "rid", temp); - if ((rid = pdb_get_group_rid(sampass))!=0 ) { - if (need_ldap_mod(pdb_add, sampass, PDB_GROUPSID)) { - slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_a_mod(mods, ldap_op, "primaryGroupID", temp); - } - } else if (!IS_SAM_DEFAULT(sampass, PDB_GID)) { + rid = pdb_get_group_rid(sampass); + + if ( (rid==0) && (!IS_SAM_DEFAULT(sampass, PDB_GID)) ) { rid = pdb_gid_to_group_rid(pdb_get_gid(sampass)); - slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_a_mod(mods, ldap_op, "primaryGroupID", temp); } else if (ldap_state->permit_non_unix_accounts) { rid = DOMAIN_GROUP_RID_USERS; - slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_a_mod(mods, ldap_op, "primaryGroupID", temp); } else { - DEBUG(0, ("NO group RID specified on account %s, cannot store!\n", pdb_get_username(sampass))); + DEBUG(0, ("NO group RID specified on account %s, " + "cannot store!\n", pdb_get_username(sampass))); + ldap_mods_free(*mods, 1); return False; } + slprintf(temp, sizeof(temp) - 1, "%i", rid); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_GROUPSID, "primaryGroupID", temp); /* displayName, cn, and gecos should all be the same * most easily accomplished by giving them the same OID * gecos isn't set here b/c it should be handled by the * add-user script - */ - if (need_ldap_mod(pdb_add, sampass, PDB_FULLNAME)) { - make_a_mod(mods, ldap_op, "displayName", pdb_get_fullname(sampass)); - make_a_mod(mods, ldap_op, "cn", pdb_get_fullname(sampass)); - } - if (need_ldap_mod(pdb_add, sampass, PDB_ACCTDESC)) { - make_a_mod(mods, ldap_op, "description", pdb_get_acct_desc(sampass)); - } - if (need_ldap_mod(pdb_add, sampass, PDB_WORKSTATIONS)) { - make_a_mod(mods, ldap_op, "userWorkstations", pdb_get_workstations(sampass)); - } - /* - * Only updates fields which have been set (not defaults from smb.conf) + * We change displayName only and fall back to cn if + * it does not exist. */ - if (need_ldap_mod(pdb_add, sampass, PDB_SMBHOME)) { - make_a_mod(mods, ldap_op, "smbHome", pdb_get_homedir(sampass)); - } + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_FULLNAME, "displayName", + pdb_get_fullname(sampass)); + + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_ACCTDESC, "description", + pdb_get_acct_desc(sampass)); + + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_WORKSTATIONS, "userWorkstations", + pdb_get_workstations(sampass)); + + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_SMBHOME, "smbHome", + pdb_get_homedir(sampass)); - if (need_ldap_mod(pdb_add, sampass, PDB_DRIVE)) { - make_a_mod(mods, ldap_op, "homeDrive", pdb_get_dir_drive(sampass)); - } - - if (need_ldap_mod(pdb_add, sampass, PDB_LOGONSCRIPT)) { - make_a_mod(mods, ldap_op, "scriptPath", pdb_get_logon_script(sampass)); - } - - if (need_ldap_mod(pdb_add, sampass, PDB_PROFILE)) - make_a_mod(mods, ldap_op, "profilePath", pdb_get_profile_path(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_DRIVE, "homeDrive", + pdb_get_dir_drive(sampass)); - if (need_ldap_mod(pdb_add, sampass, PDB_LOGONTIME)) { - slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logon_time(sampass)); - make_a_mod(mods, ldap_op, "logonTime", temp); - } + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_LOGONSCRIPT, "scriptPath", + pdb_get_logon_script(sampass)); - if (need_ldap_mod(pdb_add, sampass, PDB_LOGOFFTIME)) { - slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logoff_time(sampass)); - make_a_mod(mods, ldap_op, "logoffTime", temp); - } + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_PROFILE, "profilePath", + pdb_get_profile_path(sampass)); - if (need_ldap_mod(pdb_add, sampass, PDB_KICKOFFTIME)) { - slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_kickoff_time(sampass)); - make_a_mod(mods, ldap_op, "kickoffTime", temp); - } + slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logon_time(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_LOGONTIME, "logonTime", temp); + slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logoff_time(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_LOGOFFTIME, "logoffTime", temp); - if (need_ldap_mod(pdb_add, sampass, PDB_CANCHANGETIME)) { - slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_can_change_time(sampass)); - make_a_mod(mods, ldap_op, "pwdCanChange", temp); - } + slprintf (temp, sizeof (temp) - 1, "%li", + pdb_get_kickoff_time(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_KICKOFFTIME, "kickoffTime", temp); - if (need_ldap_mod(pdb_add, sampass, PDB_MUSTCHANGETIME)) { - slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_must_change_time(sampass)); - make_a_mod(mods, ldap_op, "pwdMustChange", temp); - } + slprintf (temp, sizeof (temp) - 1, "%li", + pdb_get_pass_can_change_time(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_CANCHANGETIME, "pwdCanChange", temp); + + slprintf (temp, sizeof (temp) - 1, "%li", + pdb_get_pass_must_change_time(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_MUSTCHANGETIME, "pwdMustChange", temp); if ((pdb_get_acct_ctrl(sampass)&(ACB_WSTRUST|ACB_SVRTRUST|ACB_DOMTRUST))|| - (lp_ldap_passwd_sync()!=LDAP_PASSWD_SYNC_ONLY)) { + (lp_ldap_passwd_sync()!=LDAP_PASSWD_SYNC_ONLY)) { - if (need_ldap_mod(pdb_add, sampass, PDB_LMPASSWD)) { - pdb_sethexpwd (temp, pdb_get_lanman_passwd(sampass), pdb_get_acct_ctrl(sampass)); - make_a_mod (mods, ldap_op, "lmPassword", temp); - } - - if (need_ldap_mod(pdb_add, sampass, PDB_NTPASSWD)) { - pdb_sethexpwd (temp, pdb_get_nt_passwd(sampass), pdb_get_acct_ctrl(sampass)); - make_a_mod (mods, ldap_op, "ntPassword", temp); - } - - if (need_ldap_mod(pdb_add, sampass, PDB_PASSLASTSET)) { - slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_last_set_time(sampass)); - make_a_mod(mods, ldap_op, "pwdLastSet", temp); - } + pdb_sethexpwd (temp, pdb_get_lanman_passwd(sampass), + pdb_get_acct_ctrl(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_LMPASSWD, "lmPassword", temp); + + pdb_sethexpwd (temp, pdb_get_nt_passwd(sampass), + pdb_get_acct_ctrl(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_NTPASSWD, "ntPassword", temp); + + slprintf (temp, sizeof (temp) - 1, "%li", + pdb_get_pass_last_set_time(sampass)); + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_PASSLASTSET, "pwdLastSet", temp); } /* FIXME: Hours stuff goes in LDAP */ - if (need_ldap_mod(pdb_add, sampass, PDB_ACCTCTRL)) { - make_a_mod (mods, ldap_op, "acctFlags", pdb_encode_acct_ctrl (pdb_get_acct_ctrl(sampass), - NEW_PW_FORMAT_SPACE_PADDED_LEN)); - } - + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + PDB_ACCTCTRL, "acctFlags", + pdb_encode_acct_ctrl (pdb_get_acct_ctrl(sampass), + NEW_PW_FORMAT_SPACE_PADDED_LEN)); return True; } @@ -1890,46 +1943,46 @@ static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_A LDAPMessage *entry; LDAPMod **mods; - if (!init_ldap_from_sam(ldap_state, &mods, LDAP_MOD_REPLACE, False, newpwd)) { - DEBUG(0, ("ldapsam_update_sam_account: init_ldap_from_sam failed!\n")); - return NT_STATUS_UNSUCCESSFUL; - } - - if (mods == NULL) { - DEBUG(4,("mods is empty: nothing to update for user: %s\n",pdb_get_username(newpwd))); - return NT_STATUS_OK; - } - rc = ldapsam_search_one_user_by_name(ldap_state, pdb_get_username(newpwd), &result); if (rc != LDAP_SUCCESS) { - ldap_mods_free(mods, 1); return NT_STATUS_UNSUCCESSFUL; } if (ldap_count_entries(ldap_state->ldap_struct, result) == 0) { DEBUG(0, ("No user to modify!\n")); ldap_msgfree(result); - ldap_mods_free(mods, 1); return NT_STATUS_UNSUCCESSFUL; } entry = ldap_first_entry(ldap_state->ldap_struct, result); dn = ldap_get_dn(ldap_state->ldap_struct, entry); + + if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd)) { + DEBUG(0, ("ldapsam_update_sam_account: init_ldap_from_sam failed!\n")); + ldap_msgfree(result); + return NT_STATUS_UNSUCCESSFUL; + } + ldap_msgfree(result); + if (mods == NULL) { + DEBUG(4,("mods is empty: nothing to update for user: %s\n", + pdb_get_username(newpwd))); + ldap_mods_free(mods, 1); + return NT_STATUS_OK; + } + ret = ldapsam_modify_entry(my_methods,newpwd,dn,mods,LDAP_MOD_REPLACE, False); + ldap_mods_free(mods,1); + if (NT_STATUS_IS_ERR(ret)) { DEBUG(0,("failed to modify user with uid = %s\n", pdb_get_username(newpwd))); - ldap_mods_free(mods,1); return ret; } - - DEBUG(2, - ("successfully modified uid = %s in the LDAP database\n", - pdb_get_username(newpwd))); - ldap_mods_free(mods, 1); + DEBUG(2, ("successfully modified uid = %s in the LDAP database\n", + pdb_get_username(newpwd))); return NT_STATUS_OK; } @@ -1943,6 +1996,7 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCO int rc; pstring filter; LDAPMessage *result = NULL; + LDAPMessage *entry = NULL; pstring dn; LDAPMod **mods = NULL; int ldap_op; @@ -1984,7 +2038,6 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCO /* Check if we need to update an existing entry */ if (num_result == 1) { char *tmp; - LDAPMessage *entry; DEBUG(3,("User exists without samba properties: adding them\n")); ldap_op = LDAP_MOD_REPLACE; @@ -2003,14 +2056,15 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCO } } - ldap_msgfree(result); - - if (!init_ldap_from_sam(ldap_state, &mods, ldap_op, True, newpwd)) { + if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd)) { DEBUG(0, ("ldapsam_add_sam_account: init_ldap_from_sam failed!\n")); + ldap_msgfree(result); ldap_mods_free(mods, 1); return NT_STATUS_UNSUCCESSFUL; } + ldap_msgfree(result); + if (mods == NULL) { DEBUG(0,("mods is empty: nothing to add for user: %s\n",pdb_get_username(newpwd))); return NT_STATUS_UNSUCCESSFUL; -- cgit From 38794e945effa1b0626642ea1a80b74d9cf7e8f2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 19:39:31 +0000 Subject: Don't use errno's when they're not available (This used to be commit b757a4374832d76500a889e4785622320881018d) --- source3/libsmb/clierror.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 3889976070..4f80f274d9 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -232,12 +232,19 @@ static struct { {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, {NT_STATUS_IN_PAGE_ERROR, EFAULT}, {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, +#ifdef ETIME {NT_STATUS_TIMER_NOT_CANCELED, ETIME}, +#endif {NT_STATUS_INVALID_PARAMETER, EINVAL}, {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, {NT_STATUS_NO_SUCH_FILE, ENOENT}, +#ifdef ENODATA {NT_STATUS_END_OF_FILE, ENODATA}, +#endif +#ifdef ENOMEDIUM {NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM}, + {NT_STATUS_NO_MEDIA, ENOMEDIUM}, +#endif {NT_STATUS_NONEXISTENT_SECTOR, ESPIPE}, {NT_STATUS_NO_MEMORY, ENOMEM}, {NT_STATUS_CONFLICTING_ADDRESSES, EADDRINUSE}, @@ -270,13 +277,16 @@ static struct { {NT_STATUS_TOO_MANY_LINKS, EMLINK}, {NT_STATUS_NETWORK_BUSY, EBUSY}, {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV}, +#ifdef ELIBACC {NT_STATUS_DLL_NOT_FOUND, ELIBACC}, +#endif {NT_STATUS_PIPE_BROKEN, EPIPE}, {NT_STATUS_REMOTE_NOT_LISTENING, ECONNREFUSED}, {NT_STATUS_NETWORK_ACCESS_DENIED, EACCES}, {NT_STATUS_TOO_MANY_OPENED_FILES, EMFILE}, +#ifdef EPROTO {NT_STATUS_DEVICE_PROTOCOL_ERROR, EPROTO}, - {NT_STATUS_NO_MEDIA, ENOMEDIUM}, +#endif {NT_STATUS_FLOAT_OVERFLOW, ERANGE}, {NT_STATUS_FLOAT_UNDERFLOW, ERANGE}, {NT_STATUS_INTEGER_OVERFLOW, ERANGE}, @@ -292,15 +302,19 @@ static struct { {NT_STATUS_REMOTE_DISCONNECT, ESHUTDOWN}, {NT_STATUS_CONNECTION_DISCONNECTED, ECONNABORTED}, {NT_STATUS_CONNECTION_RESET, ENETRESET}, +#ifdef ENOTUNIQ {NT_STATUS_IP_ADDRESS_CONFLICT1, ENOTUNIQ}, {NT_STATUS_IP_ADDRESS_CONFLICT2, ENOTUNIQ}, +#endif {NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE}, {NT_STATUS_PROTOCOL_UNREACHABLE, ENOPROTOOPT}, {NT_STATUS_ADDRESS_ALREADY_EXISTS, EADDRINUSE}, {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH}, {NT_STATUS_IO_TIMEOUT, ETIMEDOUT}, {NT_STATUS_RETRY, EAGAIN}, +#ifdef ECOMM {NT_STATUS_NET_WRITE_FAULT, ECOMM}, +#endif {NT_STATUS(0), 0} }; -- cgit From ba47af4ec2c6f900c86b589b53cd238fecdba1f2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sat, 22 Mar 2003 20:48:47 +0000 Subject: Never touch complicated if/else/elsif structures :-) This repairs domain join with fully existing wks-account which I broke with my last patch... Volker (This used to be commit 582a34efbe3c1570b852c93318ff6002954ddf6a) --- source3/passdb/pdb_ldap.c | 50 +++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 7cb092a9bc..9eab2863da 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -1364,23 +1364,25 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, rid = pdb_get_user_rid(sampass); - if ( (rid==0) && (!IS_SAM_DEFAULT(sampass, PDB_UID)) ) { - rid = fallback_pdb_uid_to_user_rid(pdb_get_uid(sampass)); - } else if (ldap_state->permit_non_unix_accounts) { - rid = ldapsam_get_next_available_nua_rid(ldap_state); - if (rid == 0) { - DEBUG(0, ("NO user RID specified on account %s, and " - "findining next available NUA RID failed, " - "cannot store!\n", - pdb_get_username(sampass))); + if (rid == 0) { + if (!IS_SAM_DEFAULT(sampass, PDB_UID)) { + rid = fallback_pdb_uid_to_user_rid(pdb_get_uid(sampass)); + } else if (ldap_state->permit_non_unix_accounts) { + rid = ldapsam_get_next_available_nua_rid(ldap_state); + if (rid == 0) { + DEBUG(0, ("NO user RID specified on account %s, and " + "findining next available NUA RID failed, " + "cannot store!\n", + pdb_get_username(sampass))); + ldap_mods_free(*mods, 1); + return False; + } + } else { + DEBUG(0, ("NO user RID specified on account %s, " + "cannot store!\n", pdb_get_username(sampass))); ldap_mods_free(*mods, 1); return False; } - } else { - DEBUG(0, ("NO user RID specified on account %s, " - "cannot store!\n", pdb_get_username(sampass))); - ldap_mods_free(*mods, 1); - return False; } slprintf(temp, sizeof(temp) - 1, "%i", rid); @@ -1390,15 +1392,17 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, rid = pdb_get_group_rid(sampass); - if ( (rid==0) && (!IS_SAM_DEFAULT(sampass, PDB_GID)) ) { - rid = pdb_gid_to_group_rid(pdb_get_gid(sampass)); - } else if (ldap_state->permit_non_unix_accounts) { - rid = DOMAIN_GROUP_RID_USERS; - } else { - DEBUG(0, ("NO group RID specified on account %s, " - "cannot store!\n", pdb_get_username(sampass))); - ldap_mods_free(*mods, 1); - return False; + if (rid == 0) { + if (!IS_SAM_DEFAULT(sampass, PDB_GID)) { + rid = pdb_gid_to_group_rid(pdb_get_gid(sampass)); + } else if (ldap_state->permit_non_unix_accounts) { + rid = DOMAIN_GROUP_RID_USERS; + } else { + DEBUG(0, ("NO group RID specified on account %s, " + "cannot store!\n", pdb_get_username(sampass))); + ldap_mods_free(*mods, 1); + return False; + } } slprintf(temp, sizeof(temp) - 1, "%i", rid); -- cgit From 4985533fd3ca47d6ee2ac293ceb810fa1857abd5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 20:49:55 +0000 Subject: Use FUNCTION_MACRO, not __FUNCTION__ (This used to be commit 6df38e250af1a8e7213ad66342c71c52ce118a12) --- source3/libsmb/clientgen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index e067e92f8d..0da9a8932f 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -272,8 +272,8 @@ struct cli_state *cli_initialise(struct cli_state *cli) memset(cli->inbuf, 0, cli->bufsize); /* just becouse we over-allocate, doesn't mean it's right to use it */ - clobber_region(__FUNCTION__, __LINE__, cli->outbuf+cli->bufsize, SAFETY_MARGIN); - clobber_region(__FUNCTION__, __LINE__, cli->inbuf+cli->bufsize, SAFETY_MARGIN); + clobber_region(FUNCTION_MACRO, __LINE__, cli->outbuf+cli->bufsize, SAFETY_MARGIN); + clobber_region(FUNCTION_MACRO, __LINE__, cli->inbuf+cli->bufsize, SAFETY_MARGIN); /* initialise signing */ cli_null_set_signing(cli); -- cgit From ee529672e23026aef7eed659d091f2b0be9f1c9c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 21:59:17 +0000 Subject: Return value in non-void function (This used to be commit 0efa773bac4b9fe2f79265413c32fecce55cc369) --- source3/passdb/pdb_tdb.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c index da6fcf70fc..7e2f4b832f 100644 --- a/source3/passdb/pdb_tdb.c +++ b/source3/passdb/pdb_tdb.c @@ -990,5 +990,6 @@ int pdb_tdbsam_init(void) { smb_register_passdb("tdbsam", pdb_init_tdbsam, PASSDB_INTERFACE_VERSION); smb_register_passdb("tdbsam_nua", pdb_init_tdbsam_nua, PASSDB_INTERFACE_VERSION); + return True; } -- cgit From c8864235ba97618a63fadeaecf82bbe61c49d20f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 22:00:19 +0000 Subject: Detect missing -lroken properly on systems without krb5-config (This used to be commit 9c3b8533fc6d2a68e013668d0927d479f4ab58dd) --- source3/configure.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index b6fabe6085..053577adf6 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2145,9 +2145,10 @@ fi AC_CHECK_LIB(k5crypto, krb5_encrypt_data, [LIBS="$LIBS -lk5crypto"]) # Heimdal checks. AC_CHECK_LIB(crypto, des_set_key, [LIBS="$LIBS -lcrypto"]) - AC_CHECK_LIB(asn1, copy_Authenticator, [LIBS="$LIBS -lasn1 -lroken"]) + AC_CHECK_LIB(asn1, copy_Authenticator, [LIBS="$LIBS -lasn1"]) + AC_CHECK_LIB(roken, roken_getaddrinfo_hostspec, [LIBS="$LIBS -lroken"]) # Heimdal checks. On static Heimdal gssapi must be linked before krb5. - AC_CHECK_LIB(gssapi, gss_display_status, [LIBS="$LIBS -lgssapi -lkrb5 -lasn1"; + AC_CHECK_LIB(gssapi, gss_display_status, [LIBS="$LIBS -lgssapi -lkrb5"; AC_DEFINE(HAVE_GSSAPI,1,[Whether GSSAPI is available])]) AC_CHECK_LIB(krb5, krb5_set_real_time, [AC_DEFINE(HAVE_KRB5_SET_REAL_TIME,1,[Whether krb5_set_real_time is available])]) -- cgit From dea7597767e690168e9485dfc2efabaab2dfb4cb Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 22:04:58 +0000 Subject: Don't use EDQUOT on systems where it's not available (This used to be commit 2e1e5719f188a933e6b691fbd48037a0d29497e4) --- source3/libsmb/clierror.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index 4f80f274d9..b66a6bcba8 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -231,7 +231,12 @@ static struct { {NT_STATUS_UNSUCCESSFUL, EINVAL}, {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, {NT_STATUS_IN_PAGE_ERROR, EFAULT}, +#ifdef EDQUOT {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, + {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, + {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT}, + {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT}, +#endif #ifdef ETIME {NT_STATUS_TIMER_NOT_CANCELED, ETIME}, #endif @@ -252,7 +257,6 @@ static struct { {NT_STATUS_UNABLE_TO_FREE_VM, EADDRINUSE}, {NT_STATUS_ACCESS_DENIED, EACCES}, {NT_STATUS_BUFFER_TOO_SMALL, ENOBUFS}, - {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, {NT_STATUS_WRONG_PASSWORD, EACCES}, {NT_STATUS_LOGON_FAILURE, EACCES}, {NT_STATUS_INVALID_WORKSTATION, EACCES}, @@ -272,8 +276,6 @@ static struct { {NT_STATUS_HOST_UNREACHABLE, EHOSTUNREACH}, {NT_STATUS_CONNECTION_ABORTED, ECONNABORTED}, {NT_STATUS_CONNECTION_REFUSED, ECONNREFUSED}, - {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT}, - {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT}, {NT_STATUS_TOO_MANY_LINKS, EMLINK}, {NT_STATUS_NETWORK_BUSY, EBUSY}, {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV}, -- cgit From 1ce67b7672ab58afd76d0ad9cc0343e688c6770d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 23:25:09 +0000 Subject: Valgrind found a few memory leaks! Andrew Bartlett (This used to be commit fb680f610ceb9a0f350c99456cf7ab1a507543fe) --- source3/lib/gencache.c | 4 ++++ source3/libsmb/namecache.c | 12 ++++++++++-- source3/param/loadparm.c | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/lib/gencache.c b/source3/lib/gencache.c index eb0e0cd808..40b4d1390d 100644 --- a/source3/lib/gencache.c +++ b/source3/lib/gencache.c @@ -114,6 +114,9 @@ BOOL gencache_set(const char *keystr, const char *value, time_t timeout) if (!gencache_init()) return False; asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value); + if (!valstr) + return False; + keybuf.dptr = strdup(keystr); keybuf.dsize = strlen(keystr)+1; databuf.dptr = strdup(valstr); @@ -241,6 +244,7 @@ BOOL gencache_get(const char *keystr, char **valstr, time_t *timeout) keybuf.dptr = strdup(keystr); keybuf.dsize = strlen(keystr)+1; databuf = tdb_fetch(cache, keybuf); + SAFE_FREE(keybuf.dptr); if (databuf.dptr && databuf.dsize > TIMEOUT_LEN) { char* entry_buf = strndup(databuf.dptr, databuf.dsize); diff --git a/source3/libsmb/namecache.c b/source3/libsmb/namecache.c index 40777011a1..d3541b7719 100644 --- a/source3/libsmb/namecache.c +++ b/source3/libsmb/namecache.c @@ -118,6 +118,7 @@ BOOL namecache_store(const char *name, int name_type, time_t expiry; char *key, *value_string; int i; + BOOL ret; /* * we use gecache call to avoid annoying debug messages about @@ -152,10 +153,17 @@ BOOL namecache_store(const char *name, int name_type, * First, store the number of ip addresses and then * place each single ip */ - ipstr_list_make(&value_string, ip_list, num_names); + if (!ipstr_list_make(&value_string, ip_list, num_names)) { + SAFE_FREE(key); + SAFE_FREE(value_string); + return False; + } /* set the entry */ - return (gencache_set(key, value_string, expiry)); + ret = gencache_set(key, value_string, expiry); + SAFE_FREE(key); + SAFE_FREE(value_string); + return ret; } diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index f8a1990513..0aa5f08be7 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -3183,6 +3183,7 @@ BOOL lp_do_parameter(int snum, const char *pszParmName, const char *pszParmValue break; case P_LIST: + str_list_free(parm_ptr); *(char ***)parm_ptr = str_list_make(pszParmValue, NULL); break; -- cgit From 22e62916d8c1a8633239c77bdd996490db869b50 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 23:25:44 +0000 Subject: - Use FUNCTION_MACRO, not __FUNCTION__. - Add some const (This used to be commit e149e70717f38e082ce35d55f9b4d84ba8419af7) --- source3/lib/getsmbpass.c | 2 +- source3/lib/util.c | 2 +- source3/sam/gumm_tdb.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/lib/getsmbpass.c b/source3/lib/getsmbpass.c index c271d55404..b6ae09b318 100644 --- a/source3/lib/getsmbpass.c +++ b/source3/lib/getsmbpass.c @@ -83,7 +83,7 @@ static int tcsetattr(int fd, int flags, struct sgttyb *t) static struct termios t; #endif /* SYSV_TERMIO */ -char *getsmbpass(char *prompt) +char *getsmbpass(const char *prompt) { FILE *in, *out; int echo_off; diff --git a/source3/lib/util.c b/source3/lib/util.c index 4f564b332a..b67896c648 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1040,7 +1040,7 @@ BOOL get_mydomname(fstring my_domname) Interpret a protocol description string, with a default. ****************************************************************************/ -int interpret_protocol(char *str,int def) +int interpret_protocol(const char *str,int def) { if (strequal(str,"NT1")) return(PROTOCOL_NT1); diff --git a/source3/sam/gumm_tdb.c b/source3/sam/gumm_tdb.c index 53ea872a11..5e390490cf 100644 --- a/source3/sam/gumm_tdb.c +++ b/source3/sam/gumm_tdb.c @@ -38,8 +38,8 @@ static int tdbgumm_debug_level = DBGC_ALL; #define TDB_FORMAT_STRING "ddB" -#define TALLOC_CHECK(ptr, err, label) do { if ((ptr) == NULL) { DEBUG(0, ("%s: Out of memory!\n", __FUNCTION__)); err = NT_STATUS_NO_MEMORY; goto label; } } while(0) -#define SET_OR_FAIL(func, label) do { if (NT_STATUS_IS_ERR(func)) { DEBUG(0, ("%s: Setting gums object data failed!\n", __FUNCTION__)); goto label; } } while(0) +#define TALLOC_CHECK(ptr, err, label) do { if ((ptr) == NULL) { DEBUG(0, ("%s: Out of memory!\n", FUNCTION_MACRO)); err = NT_STATUS_NO_MEMORY; goto label; } } while(0) +#define SET_OR_FAIL(func, label) do { if (NT_STATUS_IS_ERR(func)) { DEBUG(0, ("%s: Setting gums object data failed!\n", FUNCTION_MACRO)); goto label; } } while(0) struct tdbsam2_enum_objs { uint32 type; -- cgit From 94837e2125fec8e75dceee91c09581b7be48309b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 23:48:02 +0000 Subject: Add -U, -N, -i, -A, -W to popt. (This used to be commit 5a88d78f67fd7853d6f7d5042807afa56091d52c) --- source3/include/popt_common.h | 47 +++++++++ source3/include/smb.h | 9 +- source3/lib/popt_common.c | 240 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 279 insertions(+), 17 deletions(-) create mode 100644 source3/include/popt_common.h (limited to 'source3') diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h new file mode 100644 index 0000000000..9354e8734d --- /dev/null +++ b/source3/include/popt_common.h @@ -0,0 +1,47 @@ +/* + Unix SMB/CIFS implementation. + Common popt arguments + Copyright (C) Jelmer Vernooij 2003 + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _POPT_COMMON_H +#define _POPT_COMMON_H + +/* Common popt structures */ +extern struct poptOption popt_common_debug[]; +extern struct poptOption popt_common_configfile[]; +extern struct poptOption popt_common_socket_options[]; +extern struct poptOption popt_common_version[]; +extern struct poptOption popt_common_netbios_name[]; +extern struct poptOption popt_common_log_base[]; +extern struct poptOption popt_common_credentials[]; +extern struct poptOption popt_common_scope[]; + +#define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version, 0, "Common samba options:", NULL }, +#define POPT_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL }, + +struct user_auth_info { + pstring username; + pstring password; + pstring workgroup; + BOOL got_pass; + BOOL use_kerberos; +}; + +extern struct user_auth_info cmdline_auth_info; + +#endif /* _POPT_COMMON_H */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 0506c410f3..4f37c38413 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1711,14 +1711,7 @@ typedef struct { #define DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH 14 -/* Common popt structures */ - -extern struct poptOption popt_common_debug[]; -extern struct poptOption popt_common_configfile[]; -extern struct poptOption popt_common_socket_options[]; -extern struct poptOption popt_common_version[]; -extern struct poptOption popt_common_netbios_name[]; -extern struct poptOption popt_common_log_base[]; +#include "popt_common.h" /* Module support */ typedef int (init_module_function) (void); diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 77c44f127a..03e39f5953 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -3,7 +3,7 @@ Common popt routines Copyright (C) Tim Potter 2001,2002 - Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Jelmer Vernooij 2002,2003 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 @@ -23,17 +23,20 @@ #include "includes.h" /* Handle command line options: - * d,--debuglevel - * s,--configfile - * O,--socket-options - * V,--version - * l,--log-base - * n,--netbios-name + * -d,--debuglevel + * -s,--configfile + * -O,--socket-options + * -V,--version + * -l,--log-base + * -n,--netbios-name + * -i,--scope */ extern pstring user_socket_options; extern BOOL AllowDebugChange; +struct user_auth_info cmdline_auth_info; + static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, @@ -93,13 +96,24 @@ static void popt_common_callback(poptContext con, lp_set_logfile(logfile); } break; + + case 'i': + if (arg) { + set_global_scope(arg); + } + break; } } struct poptOption popt_common_debug[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", - "DEBUGLEVEL" }, + { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, + { 0 } +}; + +struct poptOption popt_common_scope[] = { + { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, { 0 } }; @@ -132,3 +146,211 @@ struct poptOption popt_common_log_base[] = { { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files"}, { 0 } }; + +/**************************************************************************** + * get a password from a a file or file descriptor + * exit on failure + * ****************************************************************************/ +static void get_password_file(struct user_auth_info *a) +{ + int fd = -1; + char *p; + BOOL close_it = False; + pstring spec; + char pass[128]; + + if ((p = getenv("PASSWD_FD")) != NULL) { + pstrcpy(spec, "descriptor "); + pstrcat(spec, p); + sscanf(p, "%d", &fd); + close_it = False; + } else if ((p = getenv("PASSWD_FILE")) != NULL) { + fd = sys_open(p, O_RDONLY, 0); + pstrcpy(spec, p); + if (fd < 0) { + fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", + spec, strerror(errno)); + exit(1); + } + close_it = True; + } + + for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */ + p && p - pass < sizeof(pass);) { + switch (read(fd, p, 1)) { + case 1: + if (*p != '\n' && *p != '\0') { + *++p = '\0'; /* advance p, and null-terminate pass */ + break; + } + case 0: + if (p - pass) { + *p = '\0'; /* null-terminate it, just in case... */ + p = NULL; /* then force the loop condition to become false */ + break; + } else { + fprintf(stderr, "Error reading password from file %s: %s\n", + spec, "empty password\n"); + exit(1); + } + + default: + fprintf(stderr, "Error reading password from file %s: %s\n", + spec, strerror(errno)); + exit(1); + } + } + pstrcpy(a->password, pass); + if (close_it) + close(fd); +} + +static void get_credentials_file(const char *file, struct user_auth_info *info) +{ + XFILE *auth; + fstring buf; + uint16 len = 0; + char *ptr, *val, *param; + + if ((auth=x_fopen(file, O_RDONLY, 0)) == NULL) + { + /* fail if we can't open the credentials file */ + d_printf("ERROR: Unable to open credentials file!\n"); + exit(-1); + } + + while (!x_feof(auth)) + { + /* get a line from the file */ + if (!x_fgets(buf, sizeof(buf), auth)) + continue; + len = strlen(buf); + + if ((len) && (buf[len-1]=='\n')) + { + buf[len-1] = '\0'; + len--; + } + if (len == 0) + continue; + + /* break up the line into parameter & value. + * will need to eat a little whitespace possibly */ + param = buf; + if (!(ptr = strchr_m (buf, '='))) + continue; + + val = ptr+1; + *ptr = '\0'; + + /* eat leading white space */ + while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) + val++; + + if (strwicmp("password", param) == 0) + { + pstrcpy(info->password, val); + info->got_pass = True; + } + else if (strwicmp("username", param) == 0) + pstrcpy(info->username, val); + else if (strwicmp("domain", param) == 0) + pstrcpy(info->workgroup,val); + memset(buf, 0, sizeof(buf)); + } + x_fclose(auth); +} + +/* Handle command line options: + * -U,--user + * -W,--workgroup + * -A,--authentication-file + * -k,--use-kerberos + * -N,--no-pass + */ + + +static void popt_common_credentials_callback(poptContext con, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, const void *data) +{ + char *p; + + if (reason == POPT_CALLBACK_REASON_PRE) { + cmdline_auth_info.use_kerberos = False; + cmdline_auth_info.got_pass = False; + pstrcpy(cmdline_auth_info.username, "GUEST"); + + if (getenv("LOGNAME"))pstrcpy(cmdline_auth_info.username,getenv("LOGNAME")); + + if (getenv("USER")) { + pstrcpy(cmdline_auth_info.username,getenv("USER")); + + if ((p = strchr_m(cmdline_auth_info.username,'%'))) { + *p = 0; + pstrcpy(cmdline_auth_info.password,p+1); + cmdline_auth_info.got_pass = True; + memset(strchr_m(getenv("USER"),'%')+1,'X',strlen(cmdline_auth_info.password)); + } + } + + if (getenv("PASSWD")) { + pstrcpy(cmdline_auth_info.password,getenv("PASSWD")); + cmdline_auth_info.got_pass = True; + } + + if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) { + get_password_file(&cmdline_auth_info); + cmdline_auth_info.got_pass = True; + } + + return; + } + + switch(opt->val) { + case 'U': + { + char *lp; + + pstrcpy(cmdline_auth_info.username,arg); + if ((lp=strchr_m(cmdline_auth_info.username,'%'))) { + *lp = 0; + pstrcpy(cmdline_auth_info.password,lp+1); + cmdline_auth_info.got_pass = True; + memset(strchr_m(arg,'%')+1,'X',strlen(cmdline_auth_info.password)); + } + } + break; + + case 'A': + get_credentials_file(arg, &cmdline_auth_info); + break; + + case 'W': + pstrcpy(cmdline_auth_info.workgroup,arg); + break; + + case 'k': +#ifndef HAVE_KRB5 + d_printf("No kerberos support compiled in\n"); + exit(1); +#else + cmdline_auth_info.got_pass = True; +#endif + + break; + } + } + + + + struct poptOption popt_common_credentials[] = { + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, + { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, + { "no-pass", 'N', POPT_ARG_VAL, &cmdline_auth_info.got_pass, TRUE, "Don't ask for a password" }, + { "kerberos", 'k', POPT_ARG_VAL, &cmdline_auth_info.use_kerberos, TRUE, "Use kerberos (active directory) authentication" }, + { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, + { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, + { 0 } + }; -- cgit From 89cd4674156ba5a62b8c9c4d943adc372ae576f7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 23:50:11 +0000 Subject: Add nicer --help headers (This used to be commit e56ab71f1237a71c6ad4f321ce1db4e9397efd73) --- source3/nmbd/nmbd.c | 10 +++------- source3/smbd/server.c | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index fc08645f1d..a34593557e 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -3,7 +3,7 @@ NBT netbios routines and daemon - version 2 Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) Jeremy Allison 1997-2002 - Copyright (C) Jelmer Vernooij 2002 (Conversion to popt) + Copyright (C) Jelmer Vernooij 2002,2003 (Conversion to popt) 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 @@ -600,15 +600,14 @@ static BOOL open_sockets(BOOL isdaemon, int port) {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, {"hosts", 'H', POPT_ARG_STRING, dyn_LMHOSTSFILE, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, + POPT_COMMON_SAMBA {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_netbios_name }, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base }, { NULL } }; - int opt; pstring logfile; global_nmb_port = NMB_PORT; @@ -624,7 +623,7 @@ static BOOL open_sockets(BOOL isdaemon, int port) fault_setup((void (*)(void *))fault_continue ); /* POSIX demands that signals are inherited. If the invoking process has - * these signals masked, we will have problems, as we won't recieve them. */ + * these signals masked, we will have problems, as we won't receive them. */ BlockSignals(False, SIGHUP); BlockSignals(False, SIGUSR1); BlockSignals(False, SIGTERM); @@ -643,9 +642,6 @@ static BOOL open_sockets(BOOL isdaemon, int port) #endif pc = poptGetContext("nmbd", argc, argv, long_options, 0); - while((opt = poptGetNextOpt(pc)) != -1) - { } - poptFreeContext(pc); if ( opt_interactive ) { diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 96d936d3a8..627fad1572 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -669,11 +669,11 @@ static BOOL init_structs(void ) {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, + POPT_COMMON_SAMBA {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug}, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options}, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, { NULL } }; -- cgit From 6bfe8b7c161d4e44b6dc91c8ab59d3cabb4b56cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 23:51:46 +0000 Subject: Convert to popt (This used to be commit 8f285878b30bad7388f69075538c628a7e18ac8a) --- source3/Makefile.in | 6 +-- source3/utils/smbtree.c | 121 +++++++++--------------------------------------- 2 files changed, 26 insertions(+), 101 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index c4bdbe3b11..8fe7bff1ee 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -378,7 +378,7 @@ SMBCONTROL_OBJ = utils/smbcontrol.o $(LOCKING_OBJ) $(PARAM_OBJ) \ SMBTREE_OBJ = utils/smbtree.o $(LOCKING_OBJ) $(PARAM_OBJ) \ $(UBIQX_OBJ) $(PROFILE_OBJ) $(LIB_OBJ) $(LIBSMB_OBJ) \ - $(KRBCLIENT_OBJ) + $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) TESTPARM_OBJ = utils/testparm.o \ $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) $(POPT_LIB_OBJ) @@ -765,9 +765,9 @@ bin/smbcontrol@EXEEXT@: $(SMBCONTROL_OBJ) bin/.dummy @echo Linking $@ @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ $(SMBCONTROL_OBJ) $(LDFLAGS) $(LIBS) -bin/smbtree@EXEEXT@: $(SMBTREE_OBJ) bin/.dummy +bin/smbtree@EXEEXT@: $(SMBTREE_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/smbpasswd@EXEEXT@: $(SMBPASSWD_OBJ) bin/.dummy @echo Linking $@ diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 940120d644..a55dd4dd00 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -3,6 +3,7 @@ Network neighbourhood browser. Copyright (C) Tim Potter 2000 + Copyright (C) Jelmer Vernooij 2003 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 @@ -23,34 +24,11 @@ static BOOL use_bcast; -struct user_auth_info { - pstring username; - pstring password; - pstring workgroup; -}; - /* How low can we go? */ enum tree_level {LEV_WORKGROUP, LEV_SERVER, LEV_SHARE}; static enum tree_level level = LEV_SHARE; -static void usage(void) -{ - printf( -"Usage: smbtree [options]\n\ -\n\ -\t-d debuglevel set debug output level\n\ -\t-U username user to autheticate as\n\ -\t-W workgroup workgroup of user to authenticate as\n\ -\t-D list only domains (workgroups) of tree\n\ -\t-S list domains and servers of tree\n\ -\t-b use bcast instead of using the master browser\n\ -\n\ -The username can be of the form username%%password or\n\ -workgroup\\username%%password.\n\n\ -"); -} - /* Holds a list of workgroups or servers */ struct name_list { @@ -267,13 +245,19 @@ static BOOL print_tree(struct user_auth_info *user_info) ****************************************************************************/ int main(int argc,char *argv[]) { - extern char *optarg; - extern int optind; - int opt; - char *p; - struct user_auth_info user_info; - BOOL got_pass = False; - + struct poptOption long_options[] = { + POPT_AUTOHELP + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + { "broadcast", 'b', POPT_ARG_VAL, &use_bcast, True, "Use broadcast instead of using the master browser" }, + { "domains", 'D', POPT_ARG_VAL, &level, LEV_WORKGROUP, "List only domains (workgroups) of tree" }, + { "servers", 'S', POPT_ARG_VAL, &level, LEV_SERVER, "List domains(workgroups) and servers of tree" }, + { 0 } + }; + poptContext pc; + /* Initialise samba stuff */ setlinebuf(stdout); @@ -282,86 +266,27 @@ static BOOL print_tree(struct user_auth_info *user_info) setup_logging(argv[0],True); + pc = poptGetContext("smbtree", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + while(poptGetNextOpt(pc) != -1); + poptFreeContext(pc); + lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); - if (getenv("USER")) { - pstrcpy(user_info.username, getenv("USER")); - - if ((p=strchr(user_info.username, '%'))) { - *p = 0; - pstrcpy(user_info.password, p+1); - got_pass = True; - memset(strchr(getenv("USER"), '%') + 1, 'X', - strlen(user_info.password)); - } - } - - pstrcpy(user_info.workgroup, lp_workgroup()); - /* Parse command line args */ - while ((opt = getopt(argc, argv, "U:hd:W:DSb")) != EOF) { - switch (opt) { - case 'U': - pstrcpy(user_info.username,optarg); - p = strchr(user_info.username,'%'); - if (p) { - *p = 0; - pstrcpy(user_info.password, p+1); - got_pass = 1; - } - break; - - case 'b': - use_bcast = True; - break; - - case 'h': - usage(); - exit(1); - - case 'd': - DEBUGLEVEL = atoi(optarg); - break; - - case 'W': - pstrcpy(user_info.workgroup, optarg); - break; - - case 'D': - level = LEV_WORKGROUP; - break; - - case 'S': - level = LEV_SERVER; - break; - - default: - printf("Unknown option %c (%d)\n", (char)opt, opt); - exit(1); - } - } - - argc -= optind; - argv += optind; - - if (argc > 0) { - usage(); - exit(1); - } - - if (!got_pass) { + if (!cmdline_auth_info.got_pass) { char *pass = getpass("Password: "); if (pass) { - pstrcpy(user_info.password, pass); + pstrcpy(cmdline_auth_info.password, pass); } - got_pass = True; + cmdline_auth_info.got_pass = True; } /* Now do our stuff */ - if (!print_tree(&user_info)) + if (!print_tree(&cmdline_auth_info)) return 1; return 0; -- cgit From 7c7054b45ed6db42d15ff478ff894d1789f2da11 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 22 Mar 2003 23:55:33 +0000 Subject: Convert to popt. (This used to be commit 10c2fe08b6fdc2a9985a154b93555197bf5815fa) --- source3/client/client.c | 446 +++++++++--------------------------------------- 1 file changed, 85 insertions(+), 361 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 1248c25659..b917201985 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -3,6 +3,7 @@ SMB client Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) Simo Sorce 2001-2002 + Copyright (C) Jelmer Vernooij 2003 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 @@ -27,28 +28,24 @@ #define REGISTER 0 #endif -const char prog_name[] = "smbclient"; - struct cli_state *cli; extern BOOL in_client; -extern BOOL AllowDebugChange; static int port = 0; pstring cur_dir = "\\"; static pstring cd_path = ""; static pstring service; static pstring desthost; -static pstring password; static pstring username; +static pstring password; static pstring workgroup; -static char *cmdstr; -static BOOL got_user; +static BOOL use_kerberos; static BOOL got_pass; +static char *cmdstr = NULL; + static int io_bufsize = 64512; -static BOOL use_kerberos; static int name_type = 0x20; static int max_protocol = PROTOCOL_NT1; -extern pstring user_socket_options; static int process_tok(fstring tok); static int cmd_help(void); @@ -1060,7 +1057,7 @@ static int do_put(char *rname, char *lname, BOOL reput) { int fnum; XFILE *f; - int start = 0; + size_t start = 0; off_t nread = 0; char *buf = NULL; int maxwrite = io_bufsize; @@ -2472,102 +2469,6 @@ static int process(char *base_directory) return rc; } -/**************************************************************************** -usage on the program -****************************************************************************/ -static void usage(char *pname) -{ - d_printf("Usage: %s service [options]", pname); - - d_printf("\nVersion %s\n",VERSION); - d_printf("\t-s smb.conf pathname to smb.conf file\n"); - d_printf("\t-O socket_options socket options to use\n"); - d_printf("\t-R name resolve order use these name resolution services only\n"); - d_printf("\t-M host send a winpopup message to the host\n"); - d_printf("\t-i scope use this NetBIOS scope\n"); - d_printf("\t-N don't ask for a password\n"); - d_printf("\t-n netbios name. Use this name as my netbios name\n"); - d_printf("\t-d debuglevel set the debuglevel\n"); - d_printf("\t-p port connect to the specified port\n"); - d_printf("\t-l log basename. Basename for log/debug files\n"); - d_printf("\t-h Print this help message.\n"); - d_printf("\t-I dest IP use this IP to connect to\n"); - d_printf("\t-E write messages to stderr instead of stdout\n"); - d_printf("\t-k use kerberos (active directory) authentication\n"); - d_printf("\t-U username set the network username\n"); - d_printf("\t-L host get a list of shares available on a host\n"); - d_printf("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"); - d_printf("\t-m max protocol set the max protocol level\n"); - d_printf("\t-A filename get the credentials from a file\n"); - d_printf("\t-W workgroup set the workgroup name\n"); - d_printf("\t-TIXFqgbNan command line tar\n"); - d_printf("\t-D directory start from directory\n"); - d_printf("\t-c command string execute semicolon separated commands\n"); - d_printf("\t-b xmit/send buffer changes the transmit/send buffer (default: 65520)\n"); - d_printf("\n"); -} - - -/**************************************************************************** -get a password from a a file or file descriptor -exit on failure -****************************************************************************/ -static void get_password_file(void) -{ - int fd = -1; - char *p; - BOOL close_it = False; - pstring spec; - char pass[128]; - - if ((p = getenv("PASSWD_FD")) != NULL) { - pstrcpy(spec, "descriptor "); - pstrcat(spec, p); - sscanf(p, "%d", &fd); - close_it = False; - } else if ((p = getenv("PASSWD_FILE")) != NULL) { - fd = sys_open(p, O_RDONLY, 0); - pstrcpy(spec, p); - if (fd < 0) { - fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", - spec, strerror(errno)); - exit(1); - } - close_it = True; - } - - for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */ - p && p - pass < sizeof(pass);) { - switch (read(fd, p, 1)) { - case 1: - if (*p != '\n' && *p != '\0') { - *++p = '\0'; /* advance p, and null-terminate pass */ - break; - } - case 0: - if (p - pass) { - *p = '\0'; /* null-terminate it, just in case... */ - p = NULL; /* then force the loop condition to become false */ - break; - } else { - fprintf(stderr, "Error reading password from file %s: %s\n", - spec, "empty password\n"); - exit(1); - } - - default: - fprintf(stderr, "Error reading password from file %s: %s\n", - spec, strerror(errno)); - exit(1); - } - } - pstrcpy(password, pass); - if (close_it) - close(fd); -} - - - /**************************************************************************** handle a -L query ****************************************************************************/ @@ -2677,17 +2578,13 @@ static void remember_query_host(const char *arg, int main(int argc,char *argv[]) { fstring base_directory; - char *pname = argv[0]; int opt; - extern char *optarg; - extern int optind; - int old_debug; pstring query_host; BOOL message = False; extern char tar_type; pstring term_code; - pstring new_name_resolve_order; - pstring logfile; + const char *new_name_resolve_order = NULL; + poptContext pc; char *p; int rc = 0; @@ -2700,306 +2597,133 @@ static void remember_query_host(const char *arg, *query_host = 0; *base_directory = 0; - *new_name_resolve_order = 0; - - DEBUGLEVEL = 2; - AllowDebugChange = False; - - setup_logging(pname,True); - - /* - * If the -E option is given, be careful not to clobber stdout - * before processing the options. 28.Feb.99, richard@hacom.nl. - * Also pre-parse the -s option to get the service file name. - */ - - for (opt = 1; opt < argc; opt++) { - if (strcmp(argv[opt], "-E") == 0) - dbf = x_stderr; - else if(strncmp(argv[opt], "-s", 2) == 0) { - if(argv[opt][2] != '\0') - pstrcpy(dyn_CONFIGFILE, &argv[opt][2]); - else if(argv[opt+1] != NULL) { - /* - * At least one more arg left. - */ - pstrcpy(dyn_CONFIGFILE, argv[opt+1]); - } else { - usage(pname); - exit(1); - } - } - } + setup_logging(argv[0],True); + + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_netbios_name }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_scope }, + POPT_CREDENTIALS + { "name-resolve", 'R', POPT_ARG_STRING, &new_name_resolve_order, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, + { "message", 'M', POPT_ARG_STRING, NULL, 'M', "Send message", "HOST" }, + { "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" }, + { "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" }, + { "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" }, + { "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" }, + { "max-protocol", 'm', POPT_ARG_STRING, NULL, 'm', "Set the max protocol level", "LEVEL" }, + { "tar", 'T', POPT_ARG_STRING, NULL, 'T', "Command line tar", "IXFqgbNan" }, + { "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" }, + { "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" }, + { "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" }, + { "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" }, + { 0, 0, 0, 0 } + }; + + pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + poptSetOtherOptionHelp(pc, "service "); in_client = True; /* Make sure that we tell lp_load we are */ - old_debug = DEBUGLEVEL; - if (!lp_load(dyn_CONFIGFILE,True,False,False)) { - fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", - prog_name, dyn_CONFIGFILE); - } - DEBUGLEVEL = old_debug; - - pstrcpy(workgroup,lp_workgroup()); - - load_interfaces(); - - if (getenv("USER")) { - pstrcpy(username,getenv("USER")); - - /* modification to support userid%passwd syntax in the USER var - 25.Aug.97, jdblair@uab.edu */ - - if ((p=strchr_m(username,'%'))) { - *p = 0; - pstrcpy(password,p+1); - got_pass = True; - memset(strchr_m(getenv("USER"),'%')+1,'X',strlen(password)); - } - } - - /* modification to support PASSWD environmental var - 25.Aug.97, jdblair@uab.edu */ - if (getenv("PASSWD")) { - pstrcpy(password,getenv("PASSWD")); - got_pass = True; - } - - if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) { - get_password_file(); - got_pass = True; - } - - if (*username == 0 && getenv("LOGNAME")) { - pstrcpy(username,getenv("LOGNAME")); - } - - if (*username == 0) { - pstrcpy(username,"GUEST"); - } - - if (argc < 2) { - usage(pname); - exit(1); - } - - /* FIXME: At the moment, if the user should happen to give the - * options ahead of the service name (in standard Unix - * fashion) then smbclient just spits out the usage message - * with no explanation of what in particular was wrong. Is - * there any reason we can't just parse out the service name - * and password after running getopt?? -- mbp */ - if (*argv[1] != '-') { - pstrcpy(service,argv[1]); - /* Convert any '/' characters in the service name to '\' characters */ - string_replace( service, '/','\\'); - argc--; - argv++; - - if (count_chars(service,'\\') < 3) { - usage(pname); - d_printf("\n%s: Not enough '\\' characters in service\n",service); - exit(1); - } - - if (argc > 1 && (*argv[1] != '-')) { - got_pass = True; - pstrcpy(password,argv[1]); - memset(argv[1],'X',strlen(argv[1])); - argc--; - argv++; - } - } - - while ((opt = - getopt(argc, argv,"s:O:R:M:i:Nn:d:Pp:l:hI:EU:L:t:m:W:T:D:c:b:A:k")) != EOF) { + while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { - case 's': - pstrcpy(dyn_CONFIGFILE, optarg); - break; - case 'O': - pstrcpy(user_socket_options,optarg); - break; - case 'R': - pstrcpy(new_name_resolve_order, optarg); - break; case 'M': /* Messages are sent to NetBIOS name type 0x3 * (Messenger Service). Make sure we default * to port 139 instead of port 445. srl,crh */ name_type = 0x03; - pstrcpy(desthost,optarg); - if( 0 == port ) - port = 139; + pstrcpy(desthost,poptGetOptArg(pc)); + if( 0 == port ) port = 139; message = True; break; - case 'i': - set_global_scope(optarg); - break; - case 'N': - got_pass = True; - break; - case 'n': - set_global_myname(optarg); - break; - case 'd': - if (*optarg == 'A') - DEBUGLEVEL = 10000; - else - DEBUGLEVEL = atoi(optarg); - break; - case 'P': - /* not needed anymore */ - break; - case 'p': - port = atoi(optarg); - break; - case 'l': - slprintf(logfile,sizeof(logfile)-1, "%s.client",optarg); - lp_set_logfile(logfile); - break; - case 'h': - usage(pname); - exit(0); - break; case 'I': { - dest_ip = *interpret_addr2(optarg); + dest_ip = *interpret_addr2(poptGetOptArg(pc)); if (is_zero_ip(dest_ip)) exit(1); have_ip = True; } break; case 'E': - display_set_stderr(); dbf = x_stderr; - break; - case 'U': - { - char *lp; - - got_user = True; - pstrcpy(username,optarg); - if ((lp=strchr_m(username,'%'))) { - *lp = 0; - pstrcpy(password,lp+1); - got_pass = True; - memset(strchr_m(optarg,'%')+1,'X',strlen(password)); - } - } - break; - - case 'A': - { - XFILE *auth; - fstring buf; - uint16 len = 0; - char *ptr, *val, *param; - - if ((auth=x_fopen(optarg, O_RDONLY, 0)) == NULL) - { - /* fail if we can't open the credentials file */ - d_printf("ERROR: Unable to open credentials file!\n"); - exit (-1); - } - - while (!x_feof(auth)) - { - /* get a line from the file */ - if (!x_fgets(buf, sizeof(buf), auth)) - continue; - len = strlen(buf); - - if ((len) && (buf[len-1]=='\n')) - { - buf[len-1] = '\0'; - len--; - } - if (len == 0) - continue; - - /* break up the line into parameter & value. - will need to eat a little whitespace possibly */ - param = buf; - if (!(ptr = strchr_m (buf, '='))) - continue; - val = ptr+1; - *ptr = '\0'; - - /* eat leading white space */ - while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) - val++; - - if (strwicmp("password", param) == 0) - { - pstrcpy(password, val); - got_pass = True; - } - else if (strwicmp("username", param) == 0) - pstrcpy(username, val); - else if (strwicmp("domain", param) == 0) - pstrcpy(workgroup,val); - memset(buf, 0, sizeof(buf)); - } - x_fclose(auth); - } + display_set_stderr(); break; case 'L': - remember_query_host(optarg, query_host); + remember_query_host(poptGetOptArg(pc), query_host); break; case 't': - pstrcpy(term_code, optarg); + pstrcpy(term_code, poptGetOptArg(pc)); break; case 'm': - max_protocol = interpret_protocol(optarg, max_protocol); - break; - case 'W': - pstrcpy(workgroup,optarg); + max_protocol = interpret_protocol(poptGetOptArg(pc), max_protocol); break; case 'T': - if (!tar_parseargs(argc, argv, optarg, optind)) { - usage(pname); + if (!tar_parseargs(argc, argv, poptGetOptArg(pc), optind)) { + poptPrintUsage(pc, stderr, 0); exit(1); } break; case 'D': - fstrcpy(base_directory,optarg); - break; - case 'c': - cmdstr = optarg; + fstrcpy(base_directory,poptGetOptArg(pc)); break; case 'b': - io_bufsize = MAX(1, atoi(optarg)); + io_bufsize = MAX(1, atoi(poptGetOptArg(pc))); break; - case 'k': -#ifdef HAVE_KRB5 - use_kerberos = True; -#else - d_printf("No kerberos support compiled in\n"); - exit(1); -#endif - break; - default: - usage(pname); + } + } + + if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", + argv[0], dyn_CONFIGFILE); + } + + poptGetArg(pc); + + load_interfaces(); + + if(poptPeekArg(pc)) { + pstrcpy(service,poptGetArg(pc)); + /* Convert any '/' characters in the service name to '\' characters */ + string_replace(service, '/','\\'); + + if (count_chars(service,'\\') < 3) { + d_printf("\n%s: Not enough '\\' characters in service\n",service); + poptPrintUsage(pc, stderr, 0); exit(1); } } - if (use_kerberos && !got_user) - got_pass = True; + if (poptPeekArg(pc)) { + cmdline_auth_info.got_pass = True; + pstrcpy(cmdline_auth_info.password,poptGetArg(pc)); + } init_names(); - if(*new_name_resolve_order) + if(new_name_resolve_order) lp_set_name_resolve_order(new_name_resolve_order); if (!tar_type && !*query_host && !*service && !message) { - usage(pname); + poptPrintUsage(pc, stderr, 0); exit(1); } + poptFreeContext(pc); + + pstrcpy(username, cmdline_auth_info.username); + pstrcpy(password, cmdline_auth_info.password); + pstrcpy(workgroup, cmdline_auth_info.workgroup); + use_kerberos = cmdline_auth_info.use_kerberos; + got_pass = cmdline_auth_info.got_pass; + DEBUG( 3, ( "Client started (version %s).\n", VERSION ) ); if (tar_type) { -- cgit From 52cee834d0693f7d7af42fc072cb1a8f5ecfb903 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 00:10:35 +0000 Subject: Don't crash when initialising tdb fails (This used to be commit b18d02891be1ea3728239eee15a4aed3c3be2fea) --- source3/lib/account_pol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/lib/account_pol.c b/source3/lib/account_pol.c index 2e619c0c6b..e8b382c7ab 100644 --- a/source3/lib/account_pol.c +++ b/source3/lib/account_pol.c @@ -118,7 +118,7 @@ BOOL account_policy_get(int field, uint32 *value) { fstring name; - init_account_policy(); + if(!init_account_policy())return False; *value = 0; @@ -142,7 +142,7 @@ BOOL account_policy_set(int field, uint32 value) { fstring name; - init_account_policy(); + if(!init_account_policy())return False; fstrcpy(name, decode_account_policy_name(field)); if (!*name) { -- cgit From 42879b0bf3b1ae6a74dfb9932532f8fdf63d691d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 00:12:54 +0000 Subject: Move -V to -C to prevent conflict with -V for version (This used to be commit 99de90adc98b8d5354c769dcd25cc1f34d3769e9) --- source3/utils/pdbedit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index affcc75d67..17e184ea87 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -508,8 +508,9 @@ int main (int argc, char **argv) {"import", 'i', POPT_ARG_STRING, &backend_in, 0, "import user accounts from this backend", NULL}, {"export", 'e', POPT_ARG_STRING, &backend_out, 0, "export user accounts to this backend", NULL}, {"account-policy", 'P', POPT_ARG_STRING, &account_policy, 0,"value of an account policy (like maximum password age)",NULL}, - {"value", 'V', POPT_ARG_LONG, &account_policy_value, 'V',"set the account policy to this value", NULL}, + {"value", 'C', POPT_ARG_LONG, &account_policy_value, 'C',"set the account policy to this value", NULL}, {"account-control", 'c', POPT_ARG_STRING, &account_control, 0, "Values of account control", NULL}, + POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, {0,0,0,0} -- cgit From 6ab85f1997b8842646abb4f5d3299c7027f9e6aa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 00:18:44 +0000 Subject: Convert to popt. (This used to be commit 633b3eb7812dc0a58785536a1e7d28329d488b43) --- source3/Makefile.in | 5 ++- source3/utils/profiles.c | 110 ++++++++++++++++++++++++----------------------- 2 files changed, 59 insertions(+), 56 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 8fe7bff1ee..79e8272fec 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -281,6 +281,7 @@ SAMTEST_OBJ = torture/samtest.o torture/cmd_sam.o $(SAM_OBJ) $(LIB_OBJ) $(PARAM_ GROUPDB_OBJ = groupdb/mapping.o PROFILE_OBJ = profile/profile.o +PROFILES_OBJ = utils/profiles.o OPLOCK_OBJ = smbd/oplock.o smbd/oplock_irix.o smbd/oplock_linux.o @@ -725,9 +726,9 @@ bin/net@EXEEXT@: $(NET_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NET_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) @BUILD_POPT@ -bin/profiles@EXEEXT@: utils/profiles.o bin/.dummy +bin/profiles@EXEEXT@: $(PROFILES_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ utils/profiles.o $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/editreg@EXEEXT@: utils/editreg.o bin/.dummy @echo Linking $@ diff --git a/source3/utils/profiles.c b/source3/utils/profiles.c index 4f40b93810..b2b351b2fc 100644 --- a/source3/utils/profiles.c +++ b/source3/utils/profiles.c @@ -1,6 +1,7 @@ /* Samba Unix/Linux SMB client utility profiles.c Copyright (C) 2002 Richard Sharpe, rsharpe@richardsharpe.com + Copyright (C) 2003 Jelmer Vernooij 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 @@ -514,21 +515,8 @@ static void process_acl(ACL *acl, const char *prefix) } } -static void usage(void) -{ - fprintf(stderr, "usage: profiles [-c -n ] \n"); - fprintf(stderr, "Version: %s\n", VERSION); - fprintf(stderr, "\n\t-v\t sets verbose mode"); - fprintf(stderr, "\n\t-c S-1-5-21-z-y-x-oldrid - provides SID to change"); - fprintf(stderr, "\n\t-n S-1-5-21-a-b-c-newrid - provides SID to change to"); - fprintf(stderr, "\n\t\tBoth must be present if the other is."); - fprintf(stderr, "\n\t\tIf neither present, just report the SIDs found\n"); -} - int main(int argc, char *argv[]) { - extern char *optarg; - extern int optind; int opt; int fd, start = 0; char *base; @@ -540,63 +528,75 @@ int main(int argc, char *argv[]) DWORD first_sk_off, sk_off; MY_SEC_DESC *sec_desc; int *ptr; + struct poptOption long_options[] = { + POPT_AUTOHELP + { "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "Sets verbose mode" }, + { "change-sid", 'c', POPT_ARG_STRING, NULL, 'c', "Provides SID to change" }, + { "new-sid", 'n', POPT_ARG_STRING, NULL, 'n', "Provides SID to change to" }, + { 0, 0, 0, 0 } + }; - if (argc < 2) { - usage(); - exit(1); - } + poptContext pc; + + pc = poptGetContext("profiles", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, ""); /* * Now, process the arguments */ - while ((opt = getopt(argc, argv, "c:n:v")) != EOF) { + while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { - case 'c': - change = 1; - if (!get_sid(&old_sid, optarg)) { - fprintf(stderr, "Argument to -c should be a SID in form of S-1-5-...\n"); - usage(); - exit(254); - } - break; - - case 'n': - new = 1; - if (!get_sid(&new_sid, optarg)) { - fprintf(stderr, "Argument to -n should be a SID in form of S-1-5-...\n"); - usage(); - exit(253); - } - - break; - - case 'v': - verbose++; - break; + case 'c': + change = 1; + if (!get_sid(&old_sid, poptGetOptArg(pc))) { + fprintf(stderr, "Argument to -c should be a SID in form of S-1-5-...\n"); + poptPrintUsage(pc, stderr, 0); + exit(254); + } + break; + + case 'n': + new = 1; + if (!get_sid(&new_sid, poptGetOptArg(pc))) { + fprintf(stderr, "Argument to -n should be a SID in form of S-1-5-...\n"); + poptPrintUsage(pc, stderr, 0); + exit(253); + } + + break; + + case 'v': + verbose++; + break; + } + } - default: - usage(); - exit(255); - } + if (!poptPeekArg(pc)) { + poptPrintUsage(pc, stderr, 0); + exit(1); } if ((!change & new) || (change & !new)) { - fprintf(stderr, "You must specify both -c and -n if one or the other is set!\n"); - usage(); - exit(252); + fprintf(stderr, "You must specify both -c and -n if one or the other is set!\n"); + poptPrintUsage(pc, stderr, 0); + exit(252); } - fd = open(argv[optind], O_RDWR, 0000); + poptGetArg(pc); /* To get argv[0] */ + + fd = open(poptPeekArg(pc), O_RDWR, 0000); if (fd < 0) { - fprintf(stderr, "Could not open %s: %s\n", argv[optind], + fprintf(stderr, "Could not open %s: %s\n", poptPeekArg(pc), strerror(errno)); exit(2); } if (fstat(fd, &sbuf) < 0) { - fprintf(stderr, "Could not stat file %s, %s\n", argv[optind], + fprintf(stderr, "Could not stat file %s, %s\n", poptPeekArg(pc), strerror(errno)); exit(3); } @@ -609,7 +609,7 @@ int main(int argc, char *argv[]) base = mmap(&start, sbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if ((int)base == -1) { - fprintf(stderr, "Could not mmap file: %s, %s\n", argv[optind], + fprintf(stderr, "Could not mmap file: %s, %s\n", poptPeekArg(pc), strerror(errno)); exit(4); } @@ -640,7 +640,7 @@ int main(int argc, char *argv[]) if (verbose) fprintf(stdout, "Registry file size: %u\n", (unsigned int)sbuf.st_size); if (IVAL(®f_hdr->REGF_ID, 0) != REG_REGF_ID) { - fprintf(stderr, "Incorrect Registry file (doesn't have header ID): %s\n", argv[optind]); + fprintf(stderr, "Incorrect Registry file (doesn't have header ID): %s\n", poptPeekArg(pc)); exit(5); } @@ -655,7 +655,7 @@ int main(int argc, char *argv[]) */ if (IVAL(&hbin_hdr->HBIN_ID, 0) != REG_HBIN_ID) { - fprintf(stderr, "Incorrect hbin hdr: %s\n", argv[optind]); + fprintf(stderr, "Incorrect hbin hdr: %s\n", poptPeekArg(pc)); exit(6); } @@ -666,7 +666,7 @@ int main(int argc, char *argv[]) nk_hdr = (NK_HDR *)(base + 0x1000 + IVAL(®f_hdr->first_key, 0) + 4); if (SVAL(&nk_hdr->NK_ID, 0) != REG_NK_ID) { - fprintf(stderr, "Incorrect NK Header: %s\n", argv[optind]); + fprintf(stderr, "Incorrect NK Header: %s\n", poptPeekArg(pc)); exit(7); } @@ -724,6 +724,8 @@ int main(int argc, char *argv[]) munmap(base, sbuf.st_size); + poptFreeContext(pc); + close(fd); return 0; } -- cgit From 73a7abf77d5c3f03dcd7947decf6b7e2dbcfd4d5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 00:26:41 +0000 Subject: Fix typo in comment (This used to be commit e7ed8bfc24d94b0b6e70a03eaae927fe1daa7d56) --- source3/utils/profiles.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/utils/profiles.c b/source3/utils/profiles.c index b2b351b2fc..7c2d820c81 100644 --- a/source3/utils/profiles.c +++ b/source3/utils/profiles.c @@ -1,7 +1,7 @@ /* Samba Unix/Linux SMB client utility profiles.c Copyright (C) 2002 Richard Sharpe, rsharpe@richardsharpe.com - Copyright (C) 2003 Jelmer Vernooij + Copyright (C) 2003 Jelmer Vernooij (conversion to popt) 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 @@ -35,7 +35,7 @@ times... the "regf"-Block ================ -"regf" is obviosly the abbreviation for "Registry file". "regf" is the +"regf" is obviously the abbreviation for "Registry file". "regf" is the signature of the header-block which is always 4kb in size, although only the first 64 bytes seem to be used and a checksum is calculated over the first 0x200 bytes only! -- cgit From a76d82616aae98758a009dcd4c1cd5e4768b273d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 00:30:17 +0000 Subject: Use True, not TRUE (This used to be commit eeeeb37fc6de60928f7efdeb05bb2c6516f24441) --- source3/lib/popt_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 03e39f5953..3c9a87b361 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -348,8 +348,8 @@ static void popt_common_credentials_callback(poptContext con, struct poptOption popt_common_credentials[] = { { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, - { "no-pass", 'N', POPT_ARG_VAL, &cmdline_auth_info.got_pass, TRUE, "Don't ask for a password" }, - { "kerberos", 'k', POPT_ARG_VAL, &cmdline_auth_info.use_kerberos, TRUE, "Use kerberos (active directory) authentication" }, + { "no-pass", 'N', POPT_ARG_VAL, &cmdline_auth_info.got_pass, True, "Don't ask for a password" }, + { "kerberos", 'k', POPT_ARG_VAL, &cmdline_auth_info.use_kerberos, True, "Use kerberos (active directory) authentication" }, { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, { 0 } -- cgit From 8c7753e87f297d8b828e50d7fd9ed5942f0adb0e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 00:44:56 +0000 Subject: Convert to popt. (This used to be commit 5f12b246b03aef93165059f632012b6fc4706c70) --- source3/Makefile.in | 6 +- source3/utils/nmblookup.c | 222 ++++++++++++++++++---------------------------- 2 files changed, 91 insertions(+), 137 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 79e8272fec..1f8c0cf52c 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -468,7 +468,7 @@ MNT_OBJ = client/smbmnt.o UMOUNT_OBJ = client/smbumount.o NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(UBIQX_OBJ) $(LIBNMB_OBJ) \ - $(LIB_OBJ) + $(LIB_OBJ) $(POPT_LIB_OBJ) SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/utable.o \ torture/denytest.o torture/mangle_test.o @@ -786,9 +786,9 @@ bin/smbgroupedit@EXEEXT@: $(SMBGROUPEDIT_OBJ) bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(SMBGROUPEDIT_OBJ) $(LDFLAGS) $(LIBS) -bin/nmblookup@EXEEXT@: $(NMBLOOKUP_OBJ) bin/.dummy +bin/nmblookup@EXEEXT@: $(NMBLOOKUP_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/smbtorture@EXEEXT@: $(SMBTORTURE_OBJ) bin/.dummy @echo Linking $@ diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 7e0ed4a203..3ff7f6c609 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. NBT client - used to lookup netbios names Copyright (C) Andrew Tridgell 1994-1998 + Copyright (C) Jelmer Vernooij 2003 (Conversion to popt) 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 @@ -54,31 +55,6 @@ static BOOL open_sockets(void) return True; } - -/**************************************************************************** -usage on the program -****************************************************************************/ -static void usage(void) -{ - d_printf("Usage: nmblookup [options] name\n"); - d_printf("Version %s\n",VERSION); - d_printf("\t-d debuglevel set the debuglevel\n"); - d_printf("\t-B broadcast address the address to use for broadcasts\n"); - d_printf("\t-f list the NMB flags returned\n"); - d_printf("\t-U unicast address the address to use for unicast\n"); - d_printf("\t-M searches for a master browser\n"); - d_printf("\t-R set recursion desired in packet\n"); - d_printf("\t-S lookup node status as well\n"); - d_printf("\t-T translate IP addresses into names\n"); - d_printf("\t-r Use root port 137 (Win95 only replies to this)\n"); - d_printf("\t-A Do a node status on as an IP Address\n"); - d_printf("\t-i NetBIOS scope Use the given NetBIOS scope for name queries\n"); - d_printf("\t-s smb.conf file Use the given path to the smb.conf file\n"); - d_printf("\t-h Print this help message.\n"); - d_printf("\n If you specify -M and name is \"-\", nmblookup looks up __MSBROWSE__<01>\n"); - d_printf("\n"); -} - /**************************************************************************** turn a node status flags field into a string ****************************************************************************/ @@ -211,130 +187,108 @@ int main(int argc,char *argv[]) int opt; unsigned int lookup_type = 0x0; fstring lookup; - extern int optind; - extern char *optarg; BOOL find_master=False; - int i; BOOL lookup_by_ip = False; - int commandline_debuglevel = -2; - - DEBUGLEVEL = 1; - /* Prevent smb.conf setting from overridding */ - AllowDebugChange = False; - + poptContext pc; + + struct poptOption long_options[] = { + POPT_AUTOHELP + { "broadcast", 'b', POPT_ARG_STRING, NULL, 'B', "Specify address to use for broadcasts", "BROADCAST-ADDRESS" }, + { "flags", 'f', POPT_ARG_VAL, &give_flags, True, "List the NMB flags returned" }, + { "unicast", 'U', POPT_ARG_NONE, NULL, 'U', "Specify address to use for unicast" }, + { "master-browser", 'M', POPT_ARG_VAL, &find_master, True, "Search for a master browser" }, + { "recursion", 'R', POPT_ARG_VAL, &recursion_desired, True, "Set recursion desired in package" }, + { "status", 'S', POPT_ARG_VAL, &find_status, True, "Lookup node status as well" }, + { "translate", 'T', POPT_ARG_NONE, NULL, 'T', "Translate IP addresses into names" }, + { "root-port", 'r', POPT_ARG_VAL, &RootPort, True, "Use root port 137 (Win95 only replies to this)" }, + { "lookup-by-ip", 'A', POPT_ARG_VAL, &lookup_by_ip, True, "Do a node status on as an IP Address" }, + POPT_COMMON_SAMBA + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_scope }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { 0, 0, 0, 0 } + }; + *lookup = 0; setup_logging(argv[0],True); - while ((opt = getopt(argc, argv, "d:fB:U:i:s:SMrhART")) != EOF) - switch (opt) - { - case 'B': - bcast_addr = *interpret_addr2(optarg); - got_bcast = True; - use_bcast = True; - break; - case 'f': - give_flags = True; - break; - case 'U': - bcast_addr = *interpret_addr2(optarg); - got_bcast = True; - use_bcast = False; - break; - case 'T': - translate_addresses = !translate_addresses; - break; - case 'i': - set_global_scope(optarg); - break; - case 'M': - find_master = True; - break; - case 'S': - find_status = True; - break; - case 'R': - recursion_desired = True; - break; - case 'd': - commandline_debuglevel = DEBUGLEVEL = atoi(optarg); - break; - case 's': - pstrcpy(dyn_CONFIGFILE, optarg); - break; - case 'r': - RootPort = True; - break; - case 'h': - usage(); - exit(0); - break; - case 'A': - lookup_by_ip = True; - break; - default: - usage(); - exit(1); - } - - if (argc < 2) { - usage(); - exit(1); + pc = poptGetContext("nmblookup", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, " ..."); + + while ((opt = poptGetNextOpt(pc)) != -1) + switch (opt) + { + case 'B': + bcast_addr = *interpret_addr2(optarg); + got_bcast = True; + use_bcast = True; + break; + case 'U': + bcast_addr = *interpret_addr2(optarg); + got_bcast = True; + use_bcast = False; + break; + case 'T': + translate_addresses = !translate_addresses; + break; + } + + poptGetArg(pc); /* Remove argv[0] */ + + if(!poptPeekArg(pc)) { + poptPrintUsage(pc, stderr, 0); + exit(1); } if (!lp_load(dyn_CONFIGFILE,True,False,False)) { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); + fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); } - /* - * Ensure we reset DEBUGLEVEL if someone specified it - * on the command line. - */ - - if(commandline_debuglevel != -2) - DEBUGLEVEL = commandline_debuglevel; - load_interfaces(); if (!open_sockets()) return(1); - for (i=optind;i Date: Sun, 23 Mar 2003 00:47:35 +0000 Subject: We don't need optarg when we have popt (This used to be commit b46581ef153296a0a04f773115cb2ddad4d44686) --- source3/utils/nmblookup.c | 4 ++-- source3/utils/testparm.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 3ff7f6c609..97cea3a7bb 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -222,12 +222,12 @@ int main(int argc,char *argv[]) switch (opt) { case 'B': - bcast_addr = *interpret_addr2(optarg); + bcast_addr = *interpret_addr2(poptGetOptArg(pc)); got_bcast = True; use_bcast = True; break; case 'U': - bcast_addr = *interpret_addr2(optarg); + bcast_addr = *interpret_addr2(poptGetOptArg(pc)); got_bcast = True; use_bcast = False; break; diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 60243b671b..22964214be 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -188,8 +188,6 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ int main(int argc, const char *argv[]) { - extern char *optarg; - extern int optind; const char *config_file = dyn_CONFIGFILE; int s; static BOOL silent_mode = False; -- cgit From dc1c29d29cd317abb61ff6faf206f404d145359a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 01:09:43 +0000 Subject: Don't declare variables after instructions (This used to be commit 818bc35da7b66aa8c4156406b7ab3304d4c94a72) --- source3/client/client.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index b917201985..9fb843cfba 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2587,18 +2587,6 @@ static void remember_query_host(const char *arg, poptContext pc; char *p; int rc = 0; - -#ifdef KANJI - pstrcpy(term_code, KANJI); -#else /* KANJI */ - *term_code = 0; -#endif /* KANJI */ - - *query_host = 0; - *base_directory = 0; - - setup_logging(argv[0],True); - struct poptOption long_options[] = { POPT_AUTOHELP POPT_COMMON_SAMBA @@ -2625,6 +2613,18 @@ static void remember_query_host(const char *arg, { 0, 0, 0, 0 } }; + +#ifdef KANJI + pstrcpy(term_code, KANJI); +#else /* KANJI */ + *term_code = 0; +#endif /* KANJI */ + + *query_host = 0; + *base_directory = 0; + + setup_logging(argv[0],True); + pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "service "); -- cgit From a8394385e6a9a5d1ab171c2f40c195fcbf57769a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 23 Mar 2003 01:33:13 +0000 Subject: Patch from waider to update our samsync (net rpc vampire) code: - Decode all the database names, even if we don't decode their contents - Update the 'set' code to match rpc_server/srv_samr_nt.c in only recording the difference between the old and new. Andrew Bartlett (This used to be commit 6509397f91a4c218552a48a96df06e595b630898) --- source3/utils/net_rpc_samsync.c | 190 ++++++++++++++++++++++++++++++++-------- 1 file changed, 155 insertions(+), 35 deletions(-) (limited to 'source3') diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 7d5c8681ad..7460767672 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -111,6 +111,37 @@ static void display_sam_entry(SAM_DELTA_HDR *hdr_delta, SAM_DELTA_CTR *delta) case SAM_DELTA_GROUP_INFO: display_group_info(hdr_delta->target_rid, &delta->group_info); break; + /* The following types are recognised but not handled */ + case SAM_DELTA_RENAME_GROUP: + d_printf("SAM_DELTA_RENAME_GROUP not handled\n"); + break; + case SAM_DELTA_RENAME_USER: + d_printf("SAM_DELTA_RENAME_USER not handled\n"); + break; + case SAM_DELTA_RENAME_ALIAS: + d_printf("SAM_DELTA_RENAME_ALIAS not handled\n"); + break; + case SAM_DELTA_POLICY_INFO: + d_printf("SAM_DELTA_POLICY_INFO not handled\n"); + break; + case SAM_DELTA_TRUST_DOMS: + d_printf("SAM_DELTA_TRUST_DOMS not handled\n"); + break; + case SAM_DELTA_PRIVS_INFO: + d_printf("SAM_DELTA_PRIVS_INFO not handled\n"); + break; + case SAM_DELTA_SECRET_INFO: + d_printf("SAM_DELTA_SECRET_INFO not handled\n"); + break; + case SAM_DELTA_DELETE_GROUP: + d_printf("SAM_DELTA_DELETE_GROUP not handled\n"); + break; + case SAM_DELTA_DELETE_USER: + d_printf("SAM_DELTA_DELETE_USER not handled\n"); + break; + case SAM_DELTA_MODIFIED_COUNT: + d_printf("SAM_DELTA_MODIFIED_COUNT not handled\n"); + break; default: d_printf("Unknown delta record type %d\n", hdr_delta->type); break; @@ -132,7 +163,20 @@ static void dump_database(struct cli_state *cli, unsigned db_type, DOM_CRED *ret return; } - d_printf("Dumping database %u\n", db_type); + switch( db_type ) { + case SAM_DATABASE_DOMAIN: + d_printf("Dumping DOMAIN database\n"); + break; + case SAM_DATABASE_BUILTIN: + d_printf("Dumping BUILTIN database\n"); + break; + case SAM_DATABASE_PRIVS: + d_printf("Dumping PRIVS databases\n"); + break; + default: + d_printf("Dumping unknown database type %u\n", db_type ); + break; + } do { result = cli_netlogon_sam_sync(cli, mem_ctx, ret_creds, db_type, @@ -197,70 +241,143 @@ fail: } /* Convert a SAM_ACCOUNT_DELTA to a SAM_ACCOUNT. */ +#define STRING_CHANGED (old_string && !new_string) ||\ + (!old_string && new_string) ||\ + (old_string && new_string && (strcmp(old_string, new_string) != 0)) static NTSTATUS sam_account_from_delta(SAM_ACCOUNT *account, SAM_ACCOUNT_INFO *delta) { - fstring s; + const char *old_string, *new_string; + time_t unix_time, stored_time; uchar lm_passwd[16], nt_passwd[16]; static uchar zero_buf[16]; /* Username, fullname, home dir, dir drive, logon script, acct desc, workstations, profile. */ - unistr2_to_ascii(s, &delta->uni_acct_name, sizeof(s) - 1); - pdb_set_nt_username(account, s, PDB_CHANGED); + if (delta->hdr_acct_name.buffer) { + old_string = pdb_get_nt_username(account); + new_string = unistr2_static(&delta->uni_acct_name); + + if (STRING_CHANGED) { + pdb_set_nt_username(account, new_string, PDB_CHANGED); + + } + + /* Unix username is the same - for sanity */ + old_string = pdb_get_username( account ); + if (STRING_CHANGED) { + pdb_set_username(account, new_string, PDB_CHANGED); + } + } + + if (delta->hdr_full_name.buffer) { + old_string = pdb_get_fullname(account); + new_string = unistr2_static(&delta->uni_full_name); + + if (STRING_CHANGED) + pdb_set_fullname(account, new_string, PDB_CHANGED); + } - /* Unix username is the same - for sainity */ - pdb_set_username(account, s, PDB_CHANGED); + if (delta->hdr_home_dir.buffer) { + old_string = pdb_get_homedir(account); + new_string = unistr2_static(&delta->uni_home_dir); + + if (STRING_CHANGED) + pdb_set_homedir(account, new_string, PDB_CHANGED); + } - unistr2_to_ascii(s, &delta->uni_full_name, sizeof(s) - 1); - pdb_set_fullname(account, s, PDB_CHANGED); + if (delta->hdr_dir_drive.buffer) { + old_string = pdb_get_dir_drive(account); + new_string = unistr2_static(&delta->uni_dir_drive); - unistr2_to_ascii(s, &delta->uni_home_dir, sizeof(s) - 1); - pdb_set_homedir(account, s, PDB_CHANGED); + if (STRING_CHANGED) + pdb_set_dir_drive(account, new_string, PDB_CHANGED); + } - unistr2_to_ascii(s, &delta->uni_dir_drive, sizeof(s) - 1); - pdb_set_dir_drive(account, s, PDB_CHANGED); + if (delta->hdr_logon_script.buffer) { + old_string = pdb_get_logon_script(account); + new_string = unistr2_static(&delta->uni_logon_script); - unistr2_to_ascii(s, &delta->uni_logon_script, sizeof(s) - 1); - pdb_set_logon_script(account, s, PDB_CHANGED); + if (STRING_CHANGED) + pdb_set_logon_script(account, new_string, PDB_CHANGED); + } - unistr2_to_ascii(s, &delta->uni_acct_desc, sizeof(s) - 1); - pdb_set_acct_desc(account, s, PDB_CHANGED); + if (delta->hdr_acct_desc.buffer) { + old_string = pdb_get_acct_desc(account); + new_string = unistr2_static(&delta->uni_acct_desc); - unistr2_to_ascii(s, &delta->uni_workstations, sizeof(s) - 1); - pdb_set_workstations(account, s, PDB_CHANGED); + if (STRING_CHANGED) + pdb_set_acct_desc(account, new_string, PDB_CHANGED); + } - unistr2_to_ascii(s, &delta->uni_profile, sizeof(s) - 1); - pdb_set_profile_path(account, s, PDB_CHANGED); + if (delta->hdr_workstations.buffer) { + old_string = pdb_get_workstations(account); + new_string = unistr2_static(&delta->uni_workstations); - /* User and group sid */ + if (STRING_CHANGED) + pdb_set_workstations(account, new_string, PDB_CHANGED); + } - pdb_set_user_sid_from_rid(account, delta->user_rid, PDB_CHANGED); - pdb_set_group_sid_from_rid(account, delta->group_rid, PDB_CHANGED); + if (delta->hdr_profile.buffer) { + old_string = pdb_get_profile_path(account); + new_string = unistr2_static(&delta->uni_profile); + + if (STRING_CHANGED) + pdb_set_profile_path(account, new_string, PDB_CHANGED); + } + + /* User and group sid */ + if (pdb_get_user_rid(account) != delta->user_rid) + pdb_set_user_sid_from_rid(account, delta->user_rid, PDB_CHANGED); + if (pdb_get_group_rid(account) != delta->group_rid) + pdb_set_group_sid_from_rid(account, delta->group_rid, PDB_CHANGED); /* Logon and password information */ + if (!nt_time_is_zero(&delta->logon_time)) { + unix_time = nt_time_to_unix(&delta->logon_time); + stored_time = pdb_get_logon_time(account); + if (stored_time != unix_time) + pdb_set_logon_time(account, unix_time, PDB_CHANGED); + } - pdb_set_logon_time(account, nt_time_to_unix(&delta->logon_time), PDB_CHANGED); - pdb_set_logoff_time(account, nt_time_to_unix(&delta->logoff_time), - PDB_CHANGED); - pdb_set_logon_divs(account, delta->logon_divs, PDB_CHANGED); + if (!nt_time_is_zero(&delta->logoff_time)) { + unix_time = nt_time_to_unix(&delta->logoff_time); + stored_time = pdb_get_logoff_time(account); + if (stored_time != unix_time) + pdb_set_logoff_time(account, unix_time,PDB_CHANGED); + } + + if (pdb_get_logon_divs(account) != delta->logon_divs) + pdb_set_logon_divs(account, delta->logon_divs, PDB_CHANGED); /* TODO: logon hours */ /* TODO: bad password count */ /* TODO: logon count */ - pdb_set_pass_last_set_time( - account, nt_time_to_unix(&delta->pwd_last_set_time), PDB_CHANGED); + if (!nt_time_is_zero(&delta->pwd_last_set_time)) { + unix_time = nt_time_to_unix(&delta->pwd_last_set_time); + stored_time = pdb_get_pass_last_set_time(account); + if (stored_time != unix_time) + pdb_set_pass_last_set_time(account, unix_time, PDB_CHANGED); + } - pdb_set_kickoff_time(account, get_time_t_max(), PDB_CHANGED); +#if 0 +/* No kickoff time in the delta? */ + if (!nt_time_is_zero(&delta->kickoff_time)) { + unix_time = nt_time_to_unix(&delta->kickoff_time); + stored_time = pdb_get_kickoff_time(account); + if (stored_time != unix_time) + pdb_set_kickoff_time(account, unix_time, PDB_CHANGED); + } +#endif /* Decode hashes from password hash Note that win2000 may send us all zeros for the hashes if it doesn't think this channel is secure enough - don't set the passwords at all in that case - */ + */ if (memcmp(delta->pass.buf_lm_pwd, zero_buf, 16) != 0) { sam_pwd_hash(delta->user_rid, delta->pass.buf_lm_pwd, lm_passwd, 0); pdb_set_lanman_passwd(account, lm_passwd, PDB_CHANGED); @@ -273,7 +390,9 @@ sam_account_from_delta(SAM_ACCOUNT *account, SAM_ACCOUNT_INFO *delta) /* TODO: account expiry time */ - pdb_set_acct_ctrl(account, delta->acb_info, PDB_CHANGED); + if (pdb_get_acct_ctrl(account) != delta->acb_info) + pdb_set_acct_ctrl(account, delta->acb_info, PDB_CHANGED); + return NT_STATUS_OK; } @@ -300,7 +419,8 @@ fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) if (delta->acb_info & ACB_NORMAL) { pstrcpy(add_script, lp_adduser_script()); } else if ( (delta->acb_info & ACB_WSTRUST) || - (delta->acb_info & ACB_SVRTRUST) ) { + (delta->acb_info & ACB_SVRTRUST) || + (delta->acb_info & ACB_DOMTRUST) ) { pstrcpy(add_script, lp_addmachine_script()); } else { DEBUG(1, ("Unknown user type: %s\n", @@ -386,7 +506,7 @@ fetch_group_info(uint32 rid, SAM_GROUP_INFO *delta) /* No group found from mapping, find it from its name. */ if ((grp = getgrnam(name)) == NULL) { - /* No appropriate group found, create one */ + /* No appropriate group found, create one */ d_printf("Creating unix group: '%s'\n", name); if (smb_create_group(name, &gid) != 0) return NT_STATUS_ACCESS_DENIED; @@ -565,7 +685,7 @@ static NTSTATUS fetch_alias_info(uint32 rid, SAM_ALIAS_INFO *delta, /* No group found from mapping, find it from its name. */ if ((grp = getgrnam(name)) == NULL) { - /* No appropriate group found, create one */ + /* No appropriate group found, create one */ d_printf("Creating unix group: '%s'\n", name); if (smb_create_group(name, &gid) != 0) return NT_STATUS_ACCESS_DENIED; -- cgit From 8a55edea4d87082282af815f09e229651757b560 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Mar 2003 08:40:28 +0000 Subject: Metzes change: > Hi Volker, > > if 'displayName' is not available we should fallback to 'cn' for map->nt_name > 'cn' is used as unix group name by nss_ldap. > > and if nt_name is not available we should fail (so does this patch) Volker (This used to be commit 3a7d1e72e208b9609da4ff65d9fff9179799ecac) --- source3/passdb/pdb_ldap.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 9eab2863da..f137d27cff 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -2109,7 +2109,7 @@ static void free_private_data(void **vp) /* No need to free any further, as it is talloc()ed */ } -static const char *group_attr[] = {"gid", "ntSid", "ntGroupType", +static const char *group_attr[] = {"cn", "ntSid", "ntGroupType", "gidNumber", "displayName", "description", NULL }; @@ -2155,7 +2155,7 @@ static BOOL init_group_from_ldap(struct ldapsam_privates *ldap_state, } DEBUG(2, ("Entry found for group: %s\n", temp)); - map->gid = (uint32)atol(temp); + map->gid = (gid_t)atol(temp); if (!get_single_attribute(ldap_state->ldap_struct, entry, "ntSid", temp)) { @@ -2188,6 +2188,12 @@ static BOOL init_group_from_ldap(struct ldapsam_privates *ldap_state, temp)) { DEBUG(3, ("Attribute description not found\n")); temp[0] = '\0'; + if (!get_single_attribute(ldap_state->ldap_struct, entry, "cn", + temp)) { + DEBUG(0, ("Attributes cn not found either " + "for gidNumber(%i)\n",map->gid)); + return False; + } } fstrcpy(map->comment, temp); @@ -2300,8 +2306,8 @@ static NTSTATUS ldapsam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map, /* TODO: Escaping of name? */ snprintf(filter, sizeof(filter)-1, - "(&(objectClass=sambaGroupMapping)(displayName=%s))", - name); + "(&(objectClass=sambaGroupMapping)(|(displayName=%s)(cn=%s)))", + name, name); return ldapsam_getgroup(methods, filter, map); } -- cgit From 933b4d0d1b5a6521fea2ccad1e0ff5cad82737db Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Mar 2003 09:04:25 +0000 Subject: This adds 'ldap delete dn' as the recommended parameter for the 'ldap del only sam attr' functionality. So we are compatiple to the current SuSE patches as well as to TNG... ;-) Volker (This used to be commit 353309e2a3bc27e918bd0a6cf22833d57895fbc8) --- source3/param/loadparm.c | 9 +++++---- source3/passdb/pdb_ldap.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 0aa5f08be7..d17db16381 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -230,7 +230,7 @@ typedef struct BOOL ldap_trust_ids; char *szAclCompat; int ldap_passwd_sync; - BOOL ldap_del_only_sam; + BOOL ldap_delete_dn; BOOL bMsAddPrinterWizard; BOOL bDNSproxy; BOOL bWINSsupport; @@ -1043,7 +1043,8 @@ static struct parm_struct parm_table[] = { {"ldap ssl", P_ENUM, P_GLOBAL, &Globals.ldap_ssl, NULL, enum_ldap_ssl, FLAG_ADVANCED | FLAG_DEVELOPER}, {"ldap passwd sync", P_ENUM, P_GLOBAL, &Globals.ldap_passwd_sync, NULL, enum_ldap_passwd_sync, FLAG_ADVANCED | FLAG_DEVELOPER}, {"ldap trust ids", P_BOOL, P_GLOBAL, &Globals.ldap_trust_ids, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, - {"ldap del only sam attr", P_BOOL, P_GLOBAL, &Globals.ldap_del_only_sam, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, + {"ldap delete dn", P_BOOL, P_GLOBAL, &Globals.ldap_delete_dn, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, + {"ldap del only sam attr", P_BOOLREV, P_GLOBAL, &Globals.ldap_delete_dn, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, {"Miscellaneous Options", P_SEP, P_SEPARATOR}, {"add share command", P_STRING, P_GLOBAL, &Globals.szAddShareCommand, NULL, NULL, FLAG_ADVANCED | FLAG_DEVELOPER}, @@ -1428,7 +1429,7 @@ static void init_globals(void) string_set(&Globals.szLdapAdminDn, ""); Globals.ldap_ssl = LDAP_SSL_ON; Globals.ldap_passwd_sync = LDAP_PASSWD_SYNC_OFF; - Globals.ldap_del_only_sam = True; + Globals.ldap_delete_dn = False; /* these parameters are set to defaults that are more appropriate for the increasing samba install base: @@ -1660,7 +1661,7 @@ FN_GLOBAL_STRING(lp_ldap_admin_dn, &Globals.szLdapAdminDn) FN_GLOBAL_INTEGER(lp_ldap_ssl, &Globals.ldap_ssl) FN_GLOBAL_INTEGER(lp_ldap_passwd_sync, &Globals.ldap_passwd_sync) FN_GLOBAL_BOOL(lp_ldap_trust_ids, &Globals.ldap_trust_ids) -FN_GLOBAL_BOOL(lp_ldap_del_only_sam, &Globals.ldap_del_only_sam) +FN_GLOBAL_BOOL(lp_ldap_delete_dn, &Globals.ldap_delete_dn) FN_GLOBAL_STRING(lp_add_share_cmd, &Globals.szAddShareCommand) FN_GLOBAL_STRING(lp_change_share_cmd, &Globals.szChangeShareCommand) FN_GLOBAL_STRING(lp_delete_share_cmd, &Globals.szDeleteShareCommand) diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index f137d27cff..f4d04561c1 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -848,7 +848,7 @@ static void make_a_mod (LDAPMod *** modlist, int modop, const char *attribute, c /******************************************************************* Delete complete object or objectclass and attrs from - object found in search_result depending on lp_ldap_del_only_sam + object found in search_result depending on lp_ldap_delete_dn ******************************************************************/ static NTSTATUS ldapsam_delete_entry(struct ldapsam_privates *ldap_state, LDAPMessage *result, @@ -871,7 +871,7 @@ static NTSTATUS ldapsam_delete_entry(struct ldapsam_privates *ldap_state, entry = ldap_first_entry(ldap_state->ldap_struct, result); dn = ldap_get_dn(ldap_state->ldap_struct, entry); - if (!lp_ldap_del_only_sam()) { + if (lp_ldap_delete_dn()) { NTSTATUS ret = NT_STATUS_OK; rc = ldapsam_delete(ldap_state, dn); -- cgit From da7c72736af95b0bb53ad45a1b7ce157ebb04d04 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Mar 2003 11:44:14 +0000 Subject: The group mapping functions are not called directly anymore, but instead through the passdb interface. So we can make them static. Volker (This used to be commit a91af4bea8e761a812f5c70fdc7c7cd15366b412) --- source3/groupdb/mapping.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/groupdb/mapping.c b/source3/groupdb/mapping.c index 02fc23418f..61c0dfb4b8 100644 --- a/source3/groupdb/mapping.c +++ b/source3/groupdb/mapping.c @@ -249,7 +249,7 @@ static BOOL init_group_mapping(void) /**************************************************************************** ****************************************************************************/ -BOOL add_mapping_entry(GROUP_MAP *map, int flag) +static BOOL add_mapping_entry(GROUP_MAP *map, int flag) { TDB_DATA kbuf, dbuf; pstring key, buf; @@ -505,7 +505,7 @@ BOOL remove_privilege(PRIVILEGE_SET *priv_set, LUID_ATTR set) Return the sid and the type of the unix group. ****************************************************************************/ -BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map, BOOL with_priv) +static BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map, BOOL with_priv) { TDB_DATA kbuf, dbuf; pstring key; @@ -569,7 +569,7 @@ BOOL get_group_map_from_sid(DOM_SID sid, GROUP_MAP *map, BOOL with_priv) Return the sid and the type of the unix group. ****************************************************************************/ -BOOL get_group_map_from_gid(gid_t gid, GROUP_MAP *map, BOOL with_priv) +static BOOL get_group_map_from_gid(gid_t gid, GROUP_MAP *map, BOOL with_priv) { TDB_DATA kbuf, dbuf, newkey; fstring string_sid; @@ -634,7 +634,7 @@ BOOL get_group_map_from_gid(gid_t gid, GROUP_MAP *map, BOOL with_priv) Return the sid and the type of the unix group. ****************************************************************************/ -BOOL get_group_map_from_ntname(char *name, GROUP_MAP *map, BOOL with_priv) +static BOOL get_group_map_from_ntname(char *name, GROUP_MAP *map, BOOL with_priv) { TDB_DATA kbuf, dbuf, newkey; fstring string_sid; @@ -701,7 +701,7 @@ BOOL get_group_map_from_ntname(char *name, GROUP_MAP *map, BOOL with_priv) Remove a group mapping entry. ****************************************************************************/ -BOOL group_map_remove(DOM_SID sid) +static BOOL group_map_remove(DOM_SID sid) { TDB_DATA kbuf, dbuf; pstring key; @@ -736,7 +736,7 @@ BOOL group_map_remove(DOM_SID sid) Enumerate the group mapping. ****************************************************************************/ -BOOL enum_group_mapping(enum SID_NAME_USE sid_name_use, GROUP_MAP **rmap, +static BOOL enum_group_mapping(enum SID_NAME_USE sid_name_use, GROUP_MAP **rmap, int *num_entries, BOOL unix_only, BOOL with_priv) { TDB_DATA kbuf, dbuf, newkey; -- cgit From cf4f074b94052360a3e9c7d1e3d91ba8a3531212 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Mar 2003 11:49:24 +0000 Subject: This does two things: * pdbedit -i -e sets all SAM_ACCOUNT elements to CHANGED to satisfy the new pdb_ldap.c handling * pdbedit -g transfers group mappings. I made this separate from the user database, as current installations have to live with a split backend. So, if you are running 3_0 alphas with LDAP as a backend and upgrade to the next 3_0 alpha, you should call pdbedit -i tdbsam -e ldapsam -g to transfer your group mapping database to LDAP. You certainly have to have all your groups as posixGroup objects in LDAP and adapt the LDAP schema before this call. Volker (This used to be commit 6d3faeaef6c77e389d39b6d4660ffea13e7f25f2) --- source3/utils/pdbedit.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 17e184ea87..3dfc6206b4 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -69,6 +69,12 @@ static int export_database (struct pdb_context *in, struct pdb_context *out) { } while (NT_STATUS_IS_OK(in->pdb_getsampwent(in, user))) { + int i; + + for (i=0; ipdb_add_sam_account(out, user); if (!NT_STATUS_IS_OK(pdb_reset_sam(user))){ fprintf(stderr, "Can't reset SAM_ACCOUNT!\n"); @@ -81,6 +87,30 @@ static int export_database (struct pdb_context *in, struct pdb_context *out) { return 0; } +/********************************************************* + Add all currently available group mappings to another db + ********************************************************/ + +static int export_groups (struct pdb_context *in, struct pdb_context *out) { + GROUP_MAP *maps = NULL; + int i, entries = 0; + + if (NT_STATUS_IS_ERR(in->pdb_enum_group_mapping(in, SID_NAME_UNKNOWN, + &maps, &entries, + False, False))) { + fprintf(stderr, "Can't get group mappings!\n"); + return 1; + } + + for (i=0; ipdb_add_group_mapping_entry(out, &(maps[i])); + } + + SAFE_FREE(maps); + + return 0; +} + /********************************************************* Print info from sam structure **********************************************************/ @@ -478,6 +508,7 @@ int main (int argc, char **argv) static char *backend = NULL; static char *backend_in = NULL; static char *backend_out = NULL; + static BOOL transfer_groups = False; static char *logon_script = NULL; static char *profile_path = NULL; static char *account_control = NULL; @@ -507,6 +538,7 @@ int main (int argc, char **argv) {"backend", 'b', POPT_ARG_STRING, &backend, 0, "use different passdb backend as default backend", NULL}, {"import", 'i', POPT_ARG_STRING, &backend_in, 0, "import user accounts from this backend", NULL}, {"export", 'e', POPT_ARG_STRING, &backend_out, 0, "export user accounts to this backend", NULL}, + {"group", 'g', POPT_ARG_NONE, &transfer_groups, 0, "use -i and -e for groups", NULL}, {"account-policy", 'P', POPT_ARG_STRING, &account_policy, 0,"value of an account policy (like maximum password age)",NULL}, {"value", 'C', POPT_ARG_LONG, &account_policy_value, 'C',"set the account policy to this value", NULL}, {"account-control", 'c', POPT_ARG_STRING, &account_control, 0, "Values of account control", NULL}, @@ -624,7 +656,11 @@ int main (int argc, char **argv) } else { bout = bdef; } - return export_database(bin, bout); + if (transfer_groups) { + return export_groups(bin, bout); + } else { + return export_database(bin, bout); + } } /* if BIT_USER is defined but nothing else then threat it as -l -u for compatibility */ -- cgit From 477e1a8cee99fea4dc9d1ce2878569cc39a50db2 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 12:29:19 +0000 Subject: Don't duplicate the default group mapping functions - use the ones from passdb (This used to be commit 78e135cdb17dcf70d8a1259897fd44ecd7a4b3c6) --- source3/modules/mysql.c | 60 ------------------------------------------------- 1 file changed, 60 deletions(-) (limited to 'source3') diff --git a/source3/modules/mysql.c b/source3/modules/mysql.c index 47883ca7f7..40694d6e7d 100644 --- a/source3/modules/mysql.c +++ b/source3/modules/mysql.c @@ -893,59 +893,6 @@ static NTSTATUS mysqlsam_update_sam_account(struct pdb_methods *methods, return mysqlsam_replace_sam_account(methods, newpwd, 1); } -static NTSTATUS mysqlsam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map, - DOM_SID sid, BOOL with_priv) -{ - return get_group_map_from_sid(sid, map, with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map, - gid_t gid, BOOL with_priv) -{ - return get_group_map_from_gid(gid, map, with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map, - char *name, BOOL with_priv) -{ - return get_group_map_from_ntname(name, map, with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_add_group_mapping_entry(struct pdb_methods *methods, - GROUP_MAP *map) -{ - return add_mapping_entry(map, TDB_INSERT) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_update_group_mapping_entry(struct pdb_methods *methods, - GROUP_MAP *map) -{ - return add_mapping_entry(map, TDB_REPLACE) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_delete_group_mapping_entry(struct pdb_methods *methods, - DOM_SID sid) -{ - return group_map_remove(sid) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - -static NTSTATUS mysqlsam_enum_group_mapping(struct pdb_methods *methods, - enum SID_NAME_USE sid_name_use, - GROUP_MAP **rmap, int *num_entries, - BOOL unix_only, BOOL with_priv) -{ - return enum_group_mapping(sid_name_use, rmap, num_entries, unix_only, - with_priv) ? - NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; -} - - static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_methods ** pdb_method, const char *location) { @@ -979,13 +926,6 @@ static NTSTATUS mysqlsam_init(struct pdb_context * pdb_context, struct pdb_metho (*pdb_method)->add_sam_account = mysqlsam_add_sam_account; (*pdb_method)->update_sam_account = mysqlsam_update_sam_account; (*pdb_method)->delete_sam_account = mysqlsam_delete_sam_account; - (*pdb_method)->getgrsid = mysqlsam_getgrsid; - (*pdb_method)->getgrgid = mysqlsam_getgrgid; - (*pdb_method)->getgrnam = mysqlsam_getgrnam; - (*pdb_method)->add_group_mapping_entry = mysqlsam_add_group_mapping_entry; - (*pdb_method)->update_group_mapping_entry = mysqlsam_update_group_mapping_entry; - (*pdb_method)->delete_group_mapping_entry = mysqlsam_delete_group_mapping_entry; - (*pdb_method)->enum_group_mapping = mysqlsam_enum_group_mapping; data = talloc(pdb_context->mem_ctx, sizeof(struct pdb_mysql_data)); (*pdb_method)->private_data = data; -- cgit From be47eb50324ed97a30410af8e08b1426b4a0262a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 12:40:48 +0000 Subject: Use popt_common for -s, -d and -V (This used to be commit a1576694a6f23e1c70d7d81ac4feedd4f29c5400) --- source3/utils/net.c | 19 +++++-------------- source3/utils/net_help.c | 5 +++-- 2 files changed, 8 insertions(+), 16 deletions(-) (limited to 'source3') diff --git a/source3/utils/net.c b/source3/utils/net.c index f6b3c5c84c..33c125901b 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -78,8 +78,6 @@ static int opt_machine_pass = 0; BOOL opt_have_ip = False; struct in_addr opt_dest_ip; -extern BOOL AllowDebugChange; - /* run a function from a function table. If not found then call the specified usage function @@ -513,8 +511,6 @@ static struct functable net_func[] = { int argc_new = 0; const char ** argv_new; poptContext pc; - static char *servicesf = dyn_CONFIGFILE; - static char *debuglevel = NULL; struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, 0, 'h'}, @@ -524,7 +520,6 @@ static struct functable net_func[] = { {"ipaddress", 'I', POPT_ARG_STRING, 0,'I'}, {"port", 'p', POPT_ARG_INT, &opt_port}, {"myname", 'n', POPT_ARG_STRING, &opt_requester_name}, - {"conf", 's', POPT_ARG_STRING, &servicesf}, {"server", 'S', POPT_ARG_STRING, &opt_host}, {"container", 'c', POPT_ARG_STRING, &opt_container}, {"comment", 'C', POPT_ARG_STRING, &opt_comment}, @@ -536,8 +531,9 @@ static struct functable net_func[] = { {"force", 'f', POPT_ARG_NONE, &opt_force}, {"timeout", 't', POPT_ARG_INT, &opt_timeout}, {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass}, - {"debuglevel", 'd', POPT_ARG_STRING, &debuglevel}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + POPT_COMMON_SAMBA + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, { 0, 0, 0, 0} }; @@ -577,13 +573,8 @@ static struct functable net_func[] = { exit(1); } } - - if (debuglevel) { - debug_parse_levels(debuglevel); - AllowDebugChange = False; - } - - lp_load(servicesf,True,False,False); + + lp_load(dyn_CONFIGFILE,True,False,False); argv_new = (const char **)poptGetArgs(pc); diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c index 4000a248ff..07409aec22 100644 --- a/source3/utils/net_help.c +++ b/source3/utils/net_help.c @@ -42,11 +42,12 @@ int net_common_flags_usage(int argc, const char **argv) d_printf("Valid miscellaneous options are:\n"); /* misc options */ d_printf("\t-p or --port=\t\tconnection port on target\n"); d_printf("\t-W or --myworkgroup=\tclient workgroup\n"); - d_printf("\t-d or --debug=\t\tdebug level (0-10)\n"); + d_printf("\t-d or --debuglevel=\t\tdebug level (0-10)\n"); d_printf("\t-n or --myname=\t\tclient name\n"); d_printf("\t-U or --user=\t\tuser name\n"); - d_printf("\t-s or --conf=\t\tpathname of smb.conf file\n"); + d_printf("\t-s or --configfile=\t\tpathname of smb.conf file\n"); d_printf("\t-l or --long\t\t\tDisplay full information\n"); + d_printf("\t-V or --version\t\tPrint samba version information\n"); d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n"); return -1; } -- cgit From b6520a4d48606589d3e2eedf954415f4c86dd04f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 13:02:15 +0000 Subject: Convert to popt. (This used to be commit 83c7f1e1661da14ee46d4ca7a698728fb1beb23b) --- source3/Makefile.in | 6 +-- source3/wrepld/server.c | 110 +++++++++++------------------------------------- 2 files changed, 28 insertions(+), 88 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 1f8c0cf52c..d23a517a5f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -357,7 +357,7 @@ WREPL_OBJ1 = wrepld/server.o wrepld/process.o wrepld/parser.o wrepld/socket.o \ wrepld/partners.o WREPL_OBJ = $(WREPL_OBJ1) $(PARAM_OBJ) $(UBIQX_OBJ) \ - $(PROFILE_OBJ) $(LIB_OBJ) + $(PROFILE_OBJ) $(LIB_OBJ) $(POPT_LIB_OBJ) SWAT_OBJ1 = web/cgi.o web/diagnose.o web/startstop.o web/statuspage.o \ web/swat.o web/neg_lang.o @@ -705,9 +705,9 @@ bin/nmbd@EXEEXT@: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ -bin/wrepld@EXEEXT@: $(WREPL_OBJ) bin/.dummy +bin/wrepld@EXEEXT@: $(WREPL_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(WREPL_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(WREPL_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/swat@EXEEXT@: $(SWAT_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c index 31f260e94c..5203d33745 100644 --- a/source3/wrepld/server.c +++ b/source3/wrepld/server.c @@ -166,23 +166,6 @@ void exit_server(const char *reason) static void usage(char *pname) { - d_printf("Usage: %s [-DFSaioPh?V] [-d debuglevel] [-l log basename] [-p port]\n", pname); - d_printf(" [-O socket options] [-s services file]\n"); - d_printf("\t-D Become a daemon (default)\n"); - d_printf("\t-F Run daemon in foreground (for daemontools, etc)\n"); - d_printf("\t-S Log to stdout\n"); - d_printf("\t-a Append to log file (default)\n"); - d_printf("\t-i Run interactive (not a daemon)\n" ); - d_printf("\t-o Overwrite log file, don't append\n"); - d_printf("\t-h Print usage\n"); - d_printf("\t-? Print usage\n"); - d_printf("\t-V Print version\n"); - d_printf("\t-d debuglevel Set the debuglevel\n"); - d_printf("\t-l log basename. Basename for log/debug files\n"); - d_printf("\t-p port Listen on the specified port\n"); - d_printf("\t-O socket options Socket options\n"); - d_printf("\t-s services file. Filename of services file\n"); - d_printf("\n"); } /**************************************************************************** @@ -520,84 +503,47 @@ static void process(void) ****************************************************************************/ int main(int argc,char *argv[]) { - extern char *optarg; /* shall I run as a daemon */ - BOOL is_daemon = False; - BOOL interactive = False; - BOOL specified_logfile = False; - BOOL Fork = True; - BOOL log_stdout = False; + static BOOL is_daemon = False; + static BOOL interactive = False; + static BOOL Fork = True; + static BOOL log_stdout = False; + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base }, + { "daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon (default)" }, + { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools, etc)" }, + { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, + { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Run interactive (not a daemon)" }, + { "port", 'p', POPT_ARG_INT, &wins_port, 'p', "Listen on the specified port" }, + { 0, 0, 0, 0 } + }; int opt; - pstring logfile; + poptContext pc; #ifdef HAVE_SET_AUTH_PARAMETERS set_auth_parameters(argc,argv); #endif - /* this is for people who can't start the program correctly */ - while (argc > 1 && (*argv[1] != '-')) { - argv++; - argc--; - } + pc = poptGetContext("wrepld", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); - while ( EOF != (opt = getopt(argc, argv, "FSO:l:s:d:Dp:h?Vaiof:")) ) + while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { - case 'F': - Fork = False; - break; - case 'S': - log_stdout = True; - break; - case 'O': - pstrcpy(user_socket_options,optarg); - break; - - case 's': - pstrcpy(dyn_CONFIGFILE,optarg); - break; - - case 'l': - specified_logfile = True; - slprintf(logfile, sizeof(logfile)-1, "%s/log.wrepld", optarg); - lp_set_logfile(logfile); - break; - case 'i': interactive = True; Fork = False; log_stdout = True; break; + } + } - case 'D': - is_daemon = True; - break; - - case 'd': - if (*optarg == 'A') - DEBUGLEVEL = 10000; - else - DEBUGLEVEL = atoi(optarg); - break; - - case 'p': - wins_port = atoi(optarg); - break; - - case 'h': - case '?': - usage(argv[0]); - exit(0); - break; + poptFreeContext(pc); - case 'V': - d_printf("Version %s\n",VERSION); - exit(0); - break; - default: - DEBUG(0,("Incorrect program usage - are you sure the command line is correct?\n")); - usage(argv[0]); - exit(1); - } if (log_stdout && Fork) { d_printf("Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n"); usage(argv[0]); @@ -613,12 +559,6 @@ static void process(void) load_case_tables(); - if(!specified_logfile) { - slprintf(logfile, sizeof(logfile)-1, "%s/log.wrepld", - dyn_LOGFILEBASE); - lp_set_logfile(logfile); - } - set_remote_machine_name("wrepld", False); setup_logging(argv[0],log_stdout); -- cgit From 1f5e93e2e7dccb16da3b733fffd401867b2ea3b9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 23 Mar 2003 13:03:25 +0000 Subject: NTLM Authentication: - Add a 'privileged' mode to Winbindd. This is achieved by means of a directory under lockdir, that the admin can change the group access for. - This mode is now required to access with 'CRAP' authentication feature. - This *will* break the current SQUID helper, so I've fixed up our ntlm_auth replacement: - Update our NTLMSSP code to cope with 'datagram' mode, where we don't get a challenge. - Use this to make our ntlm_auth utility suitable for use in current Squid 2.5 servers. - Tested - works for Win2k clients, but not Win9X at present. NTLMSSP updates are needed. - Now uses fgets(), not x_fgets() to cope with Squid environment (I think somthing to do with non-blocking stdin). - Add much more robust connection code to wb_common.c - it will not connect to a server of a different protocol version, and it will automatically try and reconnect to the 'privileged' pipe if possible. - This could help with 'privileged' idmap operations etc in future. - Add a generic HEX encode routine to util_str.c, - fix a small line of dodgy C in StrnCpy_fn() - Correctly pull our 'session key' out of the info3 from th the DC. This is used in both the auth code, and in for export over the winbind pipe to ntlm_auth. - Given the user's challenge/response and access to the privileged pipe, allow external access to the 'session key'. To be used for MSCHAPv2 integration. Andrew Bartlett (This used to be commit dcdc75ebd89f504a0f6e3a3bc5b43298858d276b) --- source3/auth/auth_domain.c | 7 -- source3/auth/auth_util.c | 3 + source3/include/rpc_netlogon.h | 2 +- source3/lib/util_str.c | 24 +++++- source3/libsmb/ntlmssp.c | 50 +++++++----- source3/nsswitch/wb_common.c | 73 ++++++++++++----- source3/nsswitch/winbindd.c | 30 +++++-- source3/nsswitch/winbindd.h | 2 + source3/nsswitch/winbindd_misc.c | 17 ++++ source3/nsswitch/winbindd_nss.h | 5 +- source3/nsswitch/winbindd_pam.c | 13 ++- source3/nsswitch/winbindd_util.c | 24 ++++++ source3/rpc_client/cli_netlogon.c | 13 ++- source3/utils/ntlm_auth.c | 164 +++++++++++++++++++------------------- 14 files changed, 283 insertions(+), 144 deletions(-) (limited to 'source3') diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index 079bb49a21..7cf7ed1199 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -350,13 +350,6 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx, } else { nt_status = make_server_info_info3(mem_ctx, user_info->internal_username.str, user_info->smb_name.str, domain, server_info, &info3); -#if 0 - /* The stuff doesn't work right yet */ - SMB_ASSERT(sizeof((*server_info)->session_key) == sizeof(info3.user_sess_key)); - memcpy((*server_info)->session_key, info3.user_sess_key, sizeof((*server_info)->session_key)/* 16 */); - SamOEMhash((*server_info)->session_key, trust_passwd, sizeof((*server_info)->session_key)); -#endif - uni_group_cache_store_netlogon(mem_ctx, &info3); } diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index f4c43d2d4b..70accec406 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -1066,6 +1066,9 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, SAFE_FREE(all_group_SIDs); + memcpy((*server_info)->session_key, info3.user_sess_key, sizeof((*server_info)->session_key)/* 16 */); + memcpy((*server_info)->first_8_lm_hash, info3.padding, 8); + return NT_STATUS_OK; } diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h index fb849f8238..74e3a50ee4 100644 --- a/source3/include/rpc_netlogon.h +++ b/source3/include/rpc_netlogon.h @@ -156,7 +156,7 @@ typedef struct net_user_info_3 uint32 buffer_groups; /* undocumented buffer pointer to groups. */ uint32 user_flgs; /* user flags */ - uint8 user_sess_key[16]; /* unused user session key */ + uint8 user_sess_key[16]; /* user session key */ UNIHDR hdr_logon_srv; /* logon server unicode string header */ UNIHDR hdr_logon_dom; /* logon domain unicode string header */ diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index d1e57ed5cf..4d955c59a7 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -603,8 +603,12 @@ char *StrnCpy_fn(const char *fn, int line,char *dest,const char *src,size_t n) *dest = 0; return(dest); } - while (n-- && (*d++ = *src++)) - ; + + while (n-- && (*d = *src)) { + d++; + src++; + } + *d = 0; return(dest); } @@ -681,6 +685,22 @@ size_t strhex_to_str(char *p, size_t len, const char *strhex) return num_chars; } +/** + * Routine to print a buffer as HEX digits, into an allocated string. + */ + +void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) +{ + int i; + char *hex_buffer; + + *out_hex_buffer = smb_xmalloc((len*2)+1); + hex_buffer = *out_hex_buffer; + + for (i = 0; i < len; i++) + slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); +} + /** Check if a string is part of a list. **/ diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index 5722b8efcd..0cd1ac33ec 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -121,7 +121,8 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, { DATA_BLOB struct_blob; fstring dnsname, dnsdomname; - uint32 ntlmssp_command, neg_flags, chal_flags; + uint32 neg_flags = 0; + uint32 ntlmssp_command, chal_flags; char *cliname=NULL, *domname=NULL; const uint8 *cryptkey; const char *target_name; @@ -131,20 +132,24 @@ static NTSTATUS ntlmssp_server_negotiate(struct ntlmssp_state *ntlmssp_state, file_save("ntlmssp_negotiate.dat", request.data, request.length); #endif - if (!msrpc_parse(&request, "CddAA", - "NTLMSSP", - &ntlmssp_command, - &neg_flags, - &cliname, - &domname)) { - return NT_STATUS_INVALID_PARAMETER; + if (request.length) { + if (!msrpc_parse(&request, "CddAA", + "NTLMSSP", + &ntlmssp_command, + &neg_flags, + &cliname, + &domname)) { + DEBUG(1, ("ntlmssp_server_negotiate: failed to parse NTLMSSP:\n")); + dump_data(2, request.data, request.length); + return NT_STATUS_INVALID_PARAMETER; + } + + SAFE_FREE(cliname); + SAFE_FREE(domname); + + debug_ntlmssp_flags(neg_flags); } - - SAFE_FREE(cliname); - SAFE_FREE(domname); - - debug_ntlmssp_flags(neg_flags); - + cryptkey = ntlmssp_state->get_challenge(ntlmssp_state); data_blob_free(&ntlmssp_state->chal); @@ -268,6 +273,8 @@ static NTSTATUS ntlmssp_server_auth(struct ntlmssp_state *ntlmssp_state, &ntlmssp_state->workstation, &sess_key, &neg_flags)) { + DEBUG(1, ("ntlmssp_server_auth: failed to parse NTLMSSP:\n")); + dump_data(2, request.data, request.length); return NT_STATUS_INVALID_PARAMETER; } @@ -357,13 +364,19 @@ NTSTATUS ntlmssp_server_update(NTLMSSP_STATE *ntlmssp_state, uint32 ntlmssp_command; *reply = data_blob(NULL, 0); - if (!msrpc_parse(&request, "Cd", - "NTLMSSP", - &ntlmssp_command)) { - return NT_STATUS_INVALID_PARAMETER; + if (request.length) { + if (!msrpc_parse(&request, "Cd", + "NTLMSSP", + &ntlmssp_command)) { + return NT_STATUS_INVALID_PARAMETER; + } + } else { + /* 'datagram' mode - no neg packet */ + ntlmssp_command = NTLMSSP_NEGOTIATE; } if (ntlmssp_command != ntlmssp_state->expected_state) { + DEBUG(1, ("got NTLMSSP command %u, expected %u\n", ntlmssp_command, ntlmssp_state->expected_state)); return NT_STATUS_INVALID_PARAMETER; } @@ -372,6 +385,7 @@ NTSTATUS ntlmssp_server_update(NTLMSSP_STATE *ntlmssp_state, } else if (ntlmssp_command == NTLMSSP_AUTH) { return ntlmssp_server_auth(ntlmssp_state, request, reply); } else { + DEBUG(1, ("unknown NTLMSSP command %u\n", ntlmssp_command, ntlmssp_state->expected_state)); return NT_STATUS_INVALID_PARAMETER; } } diff --git a/source3/nsswitch/wb_common.c b/source3/nsswitch/wb_common.c index 89c751a4ef..ac1ccb217e 100644 --- a/source3/nsswitch/wb_common.c +++ b/source3/nsswitch/wb_common.c @@ -131,27 +131,16 @@ static int make_safe_fd(int fd) /* Connect to winbindd socket */ -int winbind_open_pipe_sock(void) +static int winbind_named_pipe_sock(const char *dir) { -#ifdef HAVE_UNIXSOCKET struct sockaddr_un sunaddr; - static pid_t our_pid; struct stat st; pstring path; int fd; - if (our_pid != getpid()) { - close_sock(); - our_pid = getpid(); - } - - if (winbindd_fd != -1) { - return winbindd_fd; - } - /* Check permissions on unix socket directory */ - if (lstat(WINBINDD_SOCKET_DIR, &st) == -1) { + if (lstat(dir, &st) == -1) { return -1; } @@ -162,13 +151,13 @@ int winbind_open_pipe_sock(void) /* Connect to socket */ - strncpy(path, WINBINDD_SOCKET_DIR, sizeof(path) - 1); + strncpy(path, dir, sizeof(path) - 1); path[sizeof(path) - 1] = '\0'; - strncat(path, "/", sizeof(path) - 1); + strncat(path, "/", sizeof(path) - 1 - strlen(path)); path[sizeof(path) - 1] = '\0'; - strncat(path, WINBINDD_SOCKET_NAME, sizeof(path) - 1); + strncat(path, WINBINDD_SOCKET_NAME, sizeof(path) - 1 - strlen(path)); path[sizeof(path) - 1] = '\0'; ZERO_STRUCT(sunaddr); @@ -196,16 +185,60 @@ int winbind_open_pipe_sock(void) return -1; } - if ((winbindd_fd = make_safe_fd( fd)) == -1) { - return winbindd_fd; + if ((fd = make_safe_fd( fd)) == -1) { + return fd; } - if (connect(winbindd_fd, (struct sockaddr *)&sunaddr, + if (connect(fd, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) == -1) { - close_sock(); + close(fd); return -1; } + return fd; +} + +/* Connect to winbindd socket */ + +int winbind_open_pipe_sock(void) +{ +#ifdef HAVE_UNIXSOCKET + static pid_t our_pid; + struct winbindd_request request; + struct winbindd_response response; + ZERO_STRUCT(request); + ZERO_STRUCT(response); + + if (our_pid != getpid()) { + close_sock(); + our_pid = getpid(); + } + + if (winbindd_fd != -1) { + return winbindd_fd; + } + + if ((winbindd_fd = winbind_named_pipe_sock(WINBINDD_SOCKET_DIR)) == -1) { + return -1; + } + + /* version-check the socket */ + + if ((winbindd_request(WINBINDD_INTERFACE_VERSION, &request, &response) != NSS_STATUS_SUCCESS) || (response.data.interface_version != WINBIND_INTERFACE_VERSION)) { + close_sock(); + return -1; + } + + /* try and get priv pipe */ + + if (winbindd_request(WINBINDD_PRIV_PIPE_DIR, &request, &response) == NSS_STATUS_SUCCESS) { + int fd; + if ((fd = winbind_named_pipe_sock(response.extra_data)) != -1) { + close(winbindd_fd); + winbindd_fd = fd; + } + } + return winbindd_fd; #else return -1; diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 921f7d2864..4033952a6e 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -259,6 +259,7 @@ static struct dispatch_table dispatch_table[] = { { WINBINDD_INTERFACE_VERSION, winbindd_interface_version, "INTERFACE_VERSION" }, { WINBINDD_DOMAIN_NAME, winbindd_domain_name, "DOMAIN_NAME" }, { WINBINDD_NETBIOS_NAME, winbindd_netbios_name, "NETBIOS_NAME" }, + { WINBINDD_PRIV_PIPE_DIR, winbindd_priv_pipe_dir, "WINBINDD_PRIV_PIPE_DIR" }, /* WINS functions */ @@ -305,7 +306,7 @@ static void process_request(struct winbindd_cli_state *state) /* Process a new connection by adding it to the client connection list */ -static void new_connection(int listen_sock) +static void new_connection(int listen_sock, BOOL privilaged) { struct sockaddr_un sunaddr; struct winbindd_cli_state *state; @@ -336,6 +337,8 @@ static void new_connection(int listen_sock) state->last_access = time(NULL); + state->privilaged = privilaged; + /* Add to connection list */ winbindd_add_client(state); @@ -547,7 +550,7 @@ static void process_loop(void) while (1) { struct winbindd_cli_state *state; fd_set r_fds, w_fds; - int maxfd, listen_sock, selret; + int maxfd, listen_sock, listen_priv_sock, selret; struct timeval timeout; /* Handle messages */ @@ -566,17 +569,19 @@ static void process_loop(void) /* Initialise fd lists for select() */ listen_sock = open_winbindd_socket(); + listen_priv_sock = open_winbindd_priv_socket(); - if (listen_sock == -1) { + if (listen_sock == -1 || listen_priv_sock == -1) { perror("open_winbind_socket"); exit(1); } - maxfd = listen_sock; + maxfd = MAX(listen_sock, listen_priv_sock); FD_ZERO(&r_fds); FD_ZERO(&w_fds); FD_SET(listen_sock, &r_fds); + FD_SET(listen_priv_sock, &r_fds); timeout.tv_sec = WINBINDD_ESTABLISH_LOOP; timeout.tv_usec = 0; @@ -653,7 +658,22 @@ static void process_loop(void) break; } } - new_connection(listen_sock); + /* new, non-privilaged connection */ + new_connection(listen_sock, False); + } + + if (FD_ISSET(listen_priv_sock, &r_fds)) { + while (winbindd_num_clients() > WINBINDD_MAX_SIMULTANEOUS_CLIENTS - 1) { + DEBUG(5,("winbindd: Exceeding %d client connections, removing idle connection.\n", + WINBINDD_MAX_SIMULTANEOUS_CLIENTS)); + if (!remove_idle_client()) { + DEBUG(0,("winbindd: Exceeding %d client connections, no idle connection found\n", + WINBINDD_MAX_SIMULTANEOUS_CLIENTS)); + break; + } + } + /* new, privilaged connection */ + new_connection(listen_priv_sock, True); } /* Process activity on client connections */ diff --git a/source3/nsswitch/winbindd.h b/source3/nsswitch/winbindd.h index 42ef209faf..d98ac28ab1 100644 --- a/source3/nsswitch/winbindd.h +++ b/source3/nsswitch/winbindd.h @@ -43,6 +43,8 @@ struct winbindd_cli_state { BOOL finished; /* Can delete from list */ BOOL write_extra_data; /* Write extra_data field */ time_t last_access; /* Time of last access (read or write) */ + BOOL privilaged; /* Is the client 'privilaged' */ + struct winbindd_request request; /* Request from client */ struct winbindd_response response; /* Respose to client */ struct getent_state *getpwent_state; /* State for getpwent() */ diff --git a/source3/nsswitch/winbindd_misc.c b/source3/nsswitch/winbindd_misc.c index 0b283812b2..3b44d029c0 100644 --- a/source3/nsswitch/winbindd_misc.c +++ b/source3/nsswitch/winbindd_misc.c @@ -233,3 +233,20 @@ enum winbindd_result winbindd_netbios_name(struct winbindd_cli_state *state) return WINBINDD_OK; } + +/* What's my name again? */ + +enum winbindd_result winbindd_priv_pipe_dir(struct winbindd_cli_state *state) +{ + + DEBUG(3, ("[%5d]: request location of privilaged pipe\n", state->pid)); + + state->response.extra_data = strdup(get_winbind_priv_pipe_dir()); + if (!state->response.extra_data) + return WINBINDD_ERROR; + + /* must add one to length to copy the 0 for string termination */ + state->response.length += strlen((char *)state->response.extra_data) + 1; + + return WINBINDD_OK; +} diff --git a/source3/nsswitch/winbindd_nss.h b/source3/nsswitch/winbindd_nss.h index 2c87a77100..88f4a11f87 100644 --- a/source3/nsswitch/winbindd_nss.h +++ b/source3/nsswitch/winbindd_nss.h @@ -30,7 +30,7 @@ #define WINBINDD_SOCKET_NAME "pipe" /* Name of PF_UNIX socket */ #define WINBINDD_SOCKET_DIR "/tmp/.winbindd" /* Name of PF_UNIX dir */ - +#define WINBINDD_PRIV_SOCKET_SUBDIR "winbindd_privilaged" /* name of subdirectory of lp_lockdir() to hold the 'privilaged' pipe */ #define WINBINDD_DOMAIN_ENV "WINBINDD_DOMAIN" /* Environment variables */ #define WINBINDD_DONT_ENV "_NO_WINBINDD" @@ -105,6 +105,9 @@ enum winbindd_cmd { WINBINDD_NETBIOS_NAME, /* The netbios name of the server */ /* Placeholder for end of cmd list */ + /* find the location of our privilaged pipe */ + WINBINDD_PRIV_PIPE_DIR, + WINBINDD_NUM_CMDS }; diff --git a/source3/nsswitch/winbindd_pam.c b/source3/nsswitch/winbindd_pam.c index e24afbabd6..d408a8b3ae 100644 --- a/source3/nsswitch/winbindd_pam.c +++ b/source3/nsswitch/winbindd_pam.c @@ -174,6 +174,12 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state) DATA_BLOB lm_resp, nt_resp; + if (!state->privilaged) { + DEBUG(2, ("winbindd_pam_auth_crap: non-privilaged access denied!\n")); + result = NT_STATUS_ACCESS_DENIED; + goto done; + } + /* Ensure null termination */ state->request.data.auth_crap.user[sizeof(state->request.data.auth_crap.user)-1]='\0'; @@ -272,19 +278,12 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state) result = append_info3_as_ndr(mem_ctx, state, &info3); } -#if 0 - /* we don't currently do this stuff right */ - /* Doing an assert in a daemon is going to be a pretty bad - idea. - tpot */ if (state->request.data.auth_crap.flags & WINBIND_PAM_NTKEY) { - SMB_ASSERT(sizeof(state->response.data.auth.nt_session_key) == sizeof(info3.user_sess_key)); memcpy(state->response.data.auth.nt_session_key, info3.user_sess_key, sizeof(state->response.data.auth.nt_session_key) /* 16 */); } if (state->request.data.auth_crap.flags & WINBIND_PAM_LMKEY) { - SMB_ASSERT(sizeof(state->response.data.auth.nt_session_key) <= sizeof(info3.user_sess_key)); memcpy(state->response.data.auth.first_8_lm_hash, info3.padding, sizeof(state->response.data.auth.nt_session_key) /* 16 */); } -#endif } done: diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c index fdbfd92b5a..b033380206 100644 --- a/source3/nsswitch/winbindd_util.c +++ b/source3/nsswitch/winbindd_util.c @@ -453,9 +453,15 @@ void fill_domain_username(fstring name, const char *domain, const char *user) * Winbindd socket accessor functions */ +char *get_winbind_priv_pipe_dir(void) +{ + return lock_path(WINBINDD_PRIV_SOCKET_SUBDIR); +} + /* Open the winbindd socket */ static int _winbindd_socket = -1; +static int _winbindd_priv_socket = -1; int open_winbindd_socket(void) { @@ -469,6 +475,18 @@ int open_winbindd_socket(void) return _winbindd_socket; } +int open_winbindd_priv_socket(void) +{ + if (_winbindd_priv_socket == -1) { + _winbindd_priv_socket = create_pipe_sock( + get_winbind_priv_pipe_dir(), WINBINDD_SOCKET_NAME, 0750); + DEBUG(10, ("open_winbindd_priv_socket: opened socket fd %d\n", + _winbindd_priv_socket)); + } + + return _winbindd_priv_socket; +} + /* Close the winbindd socket */ void close_winbindd_socket(void) @@ -479,6 +497,12 @@ void close_winbindd_socket(void) close(_winbindd_socket); _winbindd_socket = -1; } + if (_winbindd_priv_socket != -1) { + DEBUG(10, ("close_winbindd_socket: closing socket fd %d\n", + _winbindd_priv_socket)); + close(_winbindd_priv_socket); + _winbindd_priv_socket = -1; + } } /* diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c index cbb09803af..f83571af03 100644 --- a/source3/rpc_client/cli_netlogon.c +++ b/source3/rpc_client/cli_netlogon.c @@ -597,7 +597,7 @@ NTSTATUS cli_netlogon_sam_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx, NTSTATUS cli_netlogon_sam_network_logon(struct cli_state *cli, TALLOC_CTX *mem_ctx, const char *username, const char *domain, const char *workstation, - const uint8 chal[8], + const uint8 chal[8], DATA_BLOB lm_response, DATA_BLOB nt_response, NET_USER_INFO_3 *info3) @@ -610,6 +610,8 @@ NTSTATUS cli_netlogon_sam_network_logon(struct cli_state *cli, TALLOC_CTX *mem_c NET_ID_INFO_CTR ctr; int validation_level = 3; char *workstation_name_slash; + uint8 netlogon_sess_key[16]; + static uint8 zeros[16]; ZERO_STRUCT(q); ZERO_STRUCT(r); @@ -662,6 +664,15 @@ NTSTATUS cli_netlogon_sam_network_logon(struct cli_state *cli, TALLOC_CTX *mem_c goto done; } + ZERO_STRUCT(netlogon_sess_key); + memcpy(netlogon_sess_key, cli->sess_key, 8); + + if (memcmp(zeros, info3->user_sess_key, 16) != 0) + SamOEMhash(info3->user_sess_key, netlogon_sess_key, 16); + + if (memcmp(zeros, info3->padding, 16) != 0) + SamOEMhash(info3->padding, netlogon_sess_key, 16); + /* Return results */ result = r.status; diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index b76308c55f..ac456769f2 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -51,6 +51,8 @@ static unsigned char *lm_response; static size_t lm_response_len; static unsigned char *nt_response; static size_t nt_response_len; +static int request_lm_key; +static int request_nt_key; static char *password; @@ -197,7 +199,7 @@ static NTSTATUS winbind_pw_check(struct ntlmssp_state *ntlmssp_state) memcpy(request.data.auth_crap.lm_resp, ntlmssp_state->lm_resp.data, MIN(ntlmssp_state->lm_resp.length, sizeof(request.data.auth_crap.lm_resp))); - memcpy(request.data.auth_crap.nt_resp, ntlmssp_state->lm_resp.data, + memcpy(request.data.auth_crap.nt_resp, ntlmssp_state->nt_resp.data, MIN(ntlmssp_state->nt_resp.length, sizeof(request.data.auth_crap.nt_resp))); request.data.auth_crap.lm_resp_len = ntlmssp_state->lm_resp.length; @@ -217,10 +219,28 @@ static NTSTATUS winbind_pw_check(struct ntlmssp_state *ntlmssp_state) static void manage_squid_ntlmssp_request(enum squid_mode squid_mode, char *buf, int length) { - static NTLMSSP_STATE *ntlmssp_state; + static NTLMSSP_STATE *ntlmssp_state = NULL; DATA_BLOB request, reply; NTSTATUS nt_status; + if (strlen(buf) < 2) { + DEBUG(1, ("NTLMSSP query [%s] invalid", buf)); + x_fprintf(x_stdout, "BH\n"); + return; + } + + if (strlen(buf) > 3) { + request = base64_decode_data_blob(buf + 3); + } else if (strcmp(buf, "YR") == 0) { + request = data_blob(NULL, 0); + if (ntlmssp_state) + ntlmssp_server_end(&ntlmssp_state); + } else { + DEBUG(1, ("NTLMSSP query [%s] invalid", buf)); + x_fprintf(x_stdout, "BH\n"); + return; + } + if (!ntlmssp_state) { ntlmssp_server_start(&ntlmssp_state); ntlmssp_state->check_password = winbind_pw_check; @@ -228,15 +248,8 @@ static void manage_squid_ntlmssp_request(enum squid_mode squid_mode, ntlmssp_state->get_global_myname = get_winbind_netbios_name; } - if (strlen(buf) < 3) { - x_fprintf(x_stdout, "BH\n"); - return; - } - - request = base64_decode_data_blob(buf + 3); - - DEBUG(0, ("got NTLMSSP packet:\n")); - dump_data(0, request.data, request.length); + DEBUG(10, ("got NTLMSSP packet:\n")); + dump_data(10, request.data, request.length); nt_status = ntlmssp_server_update(ntlmssp_state, request, &reply); @@ -245,10 +258,13 @@ static void manage_squid_ntlmssp_request(enum squid_mode squid_mode, x_fprintf(x_stdout, "TT %s\n", reply_base64); SAFE_FREE(reply_base64); data_blob_free(&reply); + DEBUG(10, ("NTLMSSP challenge\n")); } else if (!NT_STATUS_IS_OK(nt_status)) { x_fprintf(x_stdout, "NA %s\n", nt_errstr(nt_status)); + DEBUG(10, ("NTLMSSP %s\n", nt_errstr(nt_status))); } else { x_fprintf(x_stdout, "AF %s\\%s\n", ntlmssp_state->domain, ntlmssp_state->user); + DEBUG(10, ("NTLMSSP OK!\n")); } data_blob_free(&request); @@ -287,10 +303,11 @@ static void manage_squid_request(enum squid_mode squid_mode) int length; char *c; static BOOL err; - - if (x_fgets(buf, sizeof(buf)-1, x_stdin) == NULL) { - DEBUG(1, ("fgets() failed! dying..... errno=%d (%s)\n", errno, - strerror(errno))); + + /* this is not a typo - x_fgets doesn't work too well under squid */ + if (fgets(buf, sizeof(buf)-1, stdin) == NULL) { + DEBUG(1, ("fgets() failed! dying..... errno=%d (%s)\n", ferror(stdin), + strerror(ferror(stdin)))); exit(1); /* BIIG buffer */ } @@ -341,12 +358,22 @@ static BOOL check_auth_crap(void) { struct winbindd_request request; struct winbindd_response response; + char *lm_key; + char *nt_key; + static uint8 zeros[16]; + NSS_STATUS result; /* Send off request */ ZERO_STRUCT(request); ZERO_STRUCT(response); + if (request_lm_key) + request.data.auth_crap.flags |= WINBIND_PAM_LMKEY; + + if (request_nt_key) + request.data.auth_crap.flags |= WINBIND_PAM_NTKEY; + fstrcpy(request.data.auth_crap.user, username); fstrcpy(request.data.auth_crap.domain, domain); @@ -373,6 +400,27 @@ static BOOL check_auth_crap(void) response.data.auth.nt_status_string, response.data.auth.nt_status); + if (response.data.auth.nt_status == 0) { + if (request_lm_key + && (memcmp(zeros, response.data.auth.first_8_lm_hash, + sizeof(response.data.auth.first_8_lm_hash)) != 0)) { + hex_encode(response.data.auth.first_8_lm_hash, + sizeof(response.data.auth.first_8_lm_hash), + &lm_key); + d_printf("LM_KEY: %s\n", lm_key); + SAFE_FREE(lm_key); + } + if (request_nt_key + && (memcmp(zeros, response.data.auth.nt_session_key, + sizeof(response.data.auth.nt_session_key)) != 0)) { + hex_encode(response.data.auth.nt_session_key, + sizeof(response.data.auth.nt_session_key), + &nt_key); + d_printf("NT_KEY: %s\n", nt_key); + SAFE_FREE(nt_key); + } + } + return result == NSS_STATUS_SUCCESS; } @@ -386,68 +434,11 @@ enum { OPT_RESPONSE, OPT_LM, OPT_NT, - OPT_PASSWORD + OPT_PASSWORD, + OPT_LM_KEY, + OPT_NT_KEY }; -/************************************************************* - Routine to set hex password characters into an allocated array. -**************************************************************/ - -static void hex_encode(const unsigned char *buff_in, size_t len, char **out_hex_buffer) -{ - int i; - char *hex_buffer; - - *out_hex_buffer = smb_xmalloc((len*2)+1); - hex_buffer = *out_hex_buffer; - - for (i = 0; i < len; i++) - slprintf(&hex_buffer[i*2], 3, "%02X", buff_in[i]); -} - -/************************************************************* - Routine to get the 32 hex characters and turn them - into a 16 byte array. -**************************************************************/ - -static BOOL hex_decode(const char *hex_buf_in, unsigned char **out_buffer, size_t *size) -{ - int i; - size_t hex_buf_in_len = strlen(hex_buf_in); - unsigned char partial_byte_hex; - unsigned char partial_byte; - const char *hexchars = "0123456789ABCDEF"; - char *p; - BOOL high = True; - - if (!hex_buf_in) - return (False); - - *size = (hex_buf_in_len + 1) / 2; - - *out_buffer = smb_xmalloc(*size); - - for (i = 0; i < hex_buf_in_len; i++) { - partial_byte_hex = toupper(hex_buf_in[i]); - - p = strchr(hexchars, partial_byte_hex); - - if (!p) - return (False); - - partial_byte = PTR_DIFF(p, hexchars); - - if (high) { - (*out_buffer)[i / 2] = (partial_byte << 4); - } else { - (*out_buffer)[i / 2] |= partial_byte; - } - high = !high; - } - return (True); -} - - int main(int argc, const char **argv) { int opt; @@ -464,6 +455,8 @@ int main(int argc, const char **argv) { "lm-response", 0, POPT_ARG_STRING, &hex_lm_response, OPT_LM, "LM Response to the challenge (HEX encoded)"}, { "nt-response", 0, POPT_ARG_STRING, &hex_nt_response, OPT_NT, "NT or NTLMv2 Response to the challenge (HEX encoded)"}, { "password", 0, POPT_ARG_STRING, &password, OPT_PASSWORD, "User's plaintext password"}, + { "request-lm-key", 0, POPT_ARG_NONE, &request_lm_key, OPT_LM_KEY, "Retreive LM session key"}, + { "request-nt-key", 0, POPT_ARG_NONE, &request_nt_key, OPT_NT_KEY, "Retreive NT session key"}, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, @@ -491,20 +484,27 @@ int main(int argc, const char **argv) while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_CHALLENGE: - if (!hex_decode(hex_challenge, &challenge, &challenge_len)) { - fprintf(stderr, "hex decode of %s failed!\n", hex_challenge); + challenge_len = strlen(hex_challenge); + challenge = smb_xmalloc((challenge_len+1)/2); + if ((challenge_len = strhex_to_str(challenge, challenge_len, hex_challenge)) != 8) { + fprintf(stderr, "hex decode of %s failed (only got %u bytes)!\n", + hex_challenge, challenge_len); exit(1); } break; case OPT_LM: - if (!hex_decode(hex_lm_response, &lm_response, &lm_response_len)) { - fprintf(stderr, "hex decode of %s failed!\n", lm_response); + lm_response_len = strlen(hex_lm_response); + lm_response = smb_xmalloc((lm_response_len+1)/2); + if ((lm_response_len = strhex_to_str(lm_response, lm_response_len, hex_lm_response)) != 24) { + fprintf(stderr, "hex decode of %s failed!\n", hex_lm_response); exit(1); } break; - case OPT_NT: - if (!hex_decode(hex_lm_response, &lm_response, &lm_response_len)) { - fprintf(stderr, "hex decode of %s failed!\n", lm_response); + case OPT_NT: + nt_response_len = strlen(hex_nt_response); + nt_response = smb_xmalloc((nt_response_len+1)/2); + if ((nt_response_len = strhex_to_str(nt_response, nt_response_len, hex_nt_response)) < 24) { + fprintf(stderr, "hex decode of %s failed!\n", hex_nt_response); exit(1); } break; -- cgit From 67cf75843e0c37cff2988c762cb51ca7b483ed6a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 13:12:04 +0000 Subject: Convert to popt. (This used to be commit 691c63ad6b522ae7984017ebadffb5c7c13f6992) --- source3/Makefile.in | 4 +-- source3/utils/editreg.c | 71 ++++++++++++++++++++----------------------------- 2 files changed, 31 insertions(+), 44 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index d23a517a5f..81af32abae 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -730,9 +730,9 @@ bin/profiles@EXEEXT@: $(PROFILES_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ -bin/editreg@EXEEXT@: utils/editreg.o bin/.dummy +bin/editreg@EXEEXT@: utils/editreg.o @BUILD_POP@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ utils/editreg.o $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ utils/editreg.o $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/smbspool@EXEEXT@: $(CUPS_OBJ) bin/.dummy @echo Linking $@ diff --git a/source3/utils/editreg.c b/source3/utils/editreg.c index 2cf8e2c9df..6b3b4516bb 100644 --- a/source3/utils/editreg.c +++ b/source3/utils/editreg.c @@ -1,6 +1,7 @@ /* Samba Unix/Linux SMB client utility editreg.c Copyright (C) 2002 Richard Sharpe, rsharpe@richardsharpe.com + Copyright (C) 2003 Jelmer Vernooij (conversion to popt) 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 @@ -307,6 +308,7 @@ Hope this helps.... (Although it was "fun" for me to uncover this things, #include #include #include +#include "popt.h" static int verbose = 0; @@ -1993,69 +1995,53 @@ int print_val(const char *path, char *val_name, int val_type, int data_len, return 1; } -void usage(void) -{ - fprintf(stderr, "Usage: editreg [-v] [-k] [-c ] \n"); - fprintf(stderr, "Version: 0.1\n\n"); - fprintf(stderr, "\n\t-v\t sets verbose mode"); - fprintf(stderr, "\n\t-c \t specifies a command file"); - fprintf(stderr, "\n"); -} - int main(int argc, char *argv[]) { REGF *regf; - extern char *optarg; - extern int optind; int opt; - int commands = 0; - char *cmd_file = NULL; + static char *cmd_file = NULL; + poptContext pc; + struct poptOption long_options[] = { + POPT_AUTOHELP + { "verbose", 'v', POPT_ARG_NONE, NULL, 'v', "Sets verbose mode" }, + { "command-file", 'c', POPT_ARG_STRING, &cmd_file, 'c', "Specifies a command file" }, + { 0, 0, 0, 0 } + }; - if (argc < 2) { - usage(); - exit(1); - } - - /* - * Now, process the arguments - */ + pc = poptGetContext("editreg", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); - while ((opt = getopt(argc, argv, "vkc:")) != EOF) { - switch (opt) { - case 'c': - commands = 1; - cmd_file = optarg; - break; + poptSetOtherOptionHelp(pc, ""); - case 'v': - verbose++; - break; + while((opt = poptGetNextOpt(pc)) != -1) + switch(opt) { + case 'v': + verbose++; + break; + } - case 'k': - break; + poptGetArg(pc); /* For argv[0] */ - default: - usage(); - exit(1); - break; - } + if (!poptPeekArg(pc)) { + poptPrintUsage(pc, stderr, 0); + exit(1); } if ((regf = nt_create_regf()) == NULL) { - fprintf(stderr, "Could not create registry object: %s\n", strerror(errno)); - exit(2); + fprintf(stderr, "Could not create registry object: %s\n", strerror(errno)); + exit(2); } - if (!nt_set_regf_input_file(regf, argv[optind])) { + if (!nt_set_regf_input_file(regf, poptPeekArg(pc))) { fprintf(stderr, "Could not set name of registry file: %s, %s\n", - argv[1], strerror(errno)); + poptPeekArg(pc), strerror(errno)); exit(3); } /* Now, open it, and bring it into memory :-) */ if (nt_load_registry(regf) < 0) { - fprintf(stderr, "Could not load registry: %s\n", argv[1]); + fprintf(stderr, "Could not load registry: %s\n", poptPeekArg(pc)); exit(4); } @@ -2065,5 +2051,6 @@ int main(int argc, char *argv[]) */ nt_key_iterator(regf, regf->root, 0, "", print_key, print_sec, print_val); + poptFreeContext(pc); return 0; } -- cgit From 8e2c74c6ee50aaf2f51a0456214ae3fc8e0c6613 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 23 Mar 2003 13:18:05 +0000 Subject: Fix compile. (This used to be commit 6fbee12a8170e0bce4e94806105786b38160ada5) --- source3/auth/auth_util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index 70accec406..a3ca0b226f 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -1066,8 +1066,8 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, SAFE_FREE(all_group_SIDs); - memcpy((*server_info)->session_key, info3.user_sess_key, sizeof((*server_info)->session_key)/* 16 */); - memcpy((*server_info)->first_8_lm_hash, info3.padding, 8); + memcpy((*server_info)->session_key, info3->user_sess_key, sizeof((*server_info)->session_key)/* 16 */); + memcpy((*server_info)->first_8_lm_hash, info3->padding, 8); return NT_STATUS_OK; } -- cgit From dc0ce6f158ec9d9bd74144f78fc0b955bb00a7f1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 23 Mar 2003 13:42:38 +0000 Subject: Convert to popt. (This used to be commit 18d52ce914715d188966be95f9e4466666a04f74) --- source3/Makefile.in | 8 ++--- source3/nsswitch/winbindd.c | 84 ++++++++++++++------------------------------- 2 files changed, 30 insertions(+), 62 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 81af32abae..6cfa9be4d4 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -574,7 +574,7 @@ WINBINDD_OBJ = \ $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \ $(LIBSMB_OBJ) $(LIBMSRPC_OBJ) $(RPC_PARSE_OBJ) \ $(PROFILE_OBJ) $(UNIGRP_OBJ) \ - $(SECRETS_OBJ) $(LIBADS_OBJ) $(KRBCLIENT_OBJ) + $(SECRETS_OBJ) $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) WBINFO_OBJ = nsswitch/wbinfo.o libsmb/smbencrypt.o libsmb/smbdes.o $(POPT_LIB_OBJ) @@ -730,7 +730,7 @@ bin/profiles@EXEEXT@: $(PROFILES_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ $(PROFILES_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ -bin/editreg@EXEEXT@: utils/editreg.o @BUILD_POP@ bin/.dummy +bin/editreg@EXEEXT@: utils/editreg.o @BUILD_POPT@ bin/.dummy @echo Linking $@ @$(CC) $(FLAGS) -o $@ utils/editreg.o $(LDFLAGS) $(LIBS) @BUILD_POPT@ @@ -922,9 +922,9 @@ nsswitch/libnss_wins.@SHLIBEXT@: $(NSS_OBJ) @$(SHLD) $(LDSHFLAGS) -o $@ $(NSS_OBJ) -lc \ @SONAMEFLAG@`basename $@` -bin/winbindd@EXEEXT@: $(WINBINDD_OBJ) bin/.dummy +bin/winbindd@EXEEXT@: $(WINBINDD_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(LINK) -o $@ $(WINBINDD_OBJ) $(DYNEXP) $(LIBS) + @$(LINK) -o $@ $(WINBINDD_OBJ) $(DYNEXP) $(LIBS) @BUILD_POPT@ nsswitch/libns_winbind.@SHLIBEXT@: $(WINBIND_NSS_PICOBJS) @echo "Linking $@" diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 4033952a6e..c9d6808316 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -5,6 +5,7 @@ Copyright (C) by Tim Potter 2000-2002 Copyright (C) Andrew Tridgell 2002 + Copyright (C) Jelmer Vernooij 2003 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 @@ -31,7 +32,6 @@ BOOL opt_dual_daemon = False; static BOOL reload_services_file(BOOL test) { BOOL ret; - pstring logfile; if (lp_loaded()) { pstring fname; @@ -806,27 +806,26 @@ BOOL winbind_setup_common(void) struct winbindd_state server_state; /* Server state information */ - -static void usage(void) -{ - printf("Usage: winbindd [options]\n"); - printf("\t-F daemon in foreground mode\n"); - printf("\t-S log to stdout\n"); - printf("\t-i interactive mode\n"); - printf("\t-B dual daemon mode\n"); - printf("\t-n disable cacheing\n"); - printf("\t-d level set debug level\n"); - printf("\t-s configfile choose smb.conf location\n"); - printf("\t-h show this help message\n"); -} - - int main(int argc, char **argv) +int main(int argc, char **argv) { - extern BOOL AllowDebugChange; pstring logfile; - BOOL interactive = False; - BOOL Fork = True; - BOOL log_stdout = False; + static BOOL interactive = False; + static BOOL Fork = True; + static BOOL log_stdout = False; + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, + { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, + { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" }, + { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" }, + { "dual-daemon", 'B', POPT_ARG_VAL, &opt_dual_daemon, True, "Dual daemon mode" }, + { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, False, "Disable caching" }, + + { 0, 0, 0, 0 } + }; + poptContext pc; int opt; /* glibc (?) likes to print "User defined signal 1" and exit if a @@ -850,56 +849,24 @@ static void usage(void) /* Initialise samba/rpc client stuff */ - while ((opt = getopt(argc, argv, "FSid:s:nhB")) != EOF) { - switch (opt) { + pc = poptGetContext("winbindd", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); - case 'F': - Fork = False; - break; - case 'S': - log_stdout = True; - break; + while ((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { /* Don't become a daemon */ case 'i': interactive = True; log_stdout = True; Fork = False; break; - - /* dual daemon system */ - case 'B': - opt_dual_daemon = True; - break; - - /* disable cacheing */ - case 'n': - opt_nocache = True; - break; - - /* Run with specified debug level */ - case 'd': - DEBUGLEVEL = atoi(optarg); - AllowDebugChange = False; - break; - - /* Load a different smb.conf file */ - case 's': - pstrcpy(dyn_CONFIGFILE,optarg); - break; - - case 'h': - usage(); - exit(0); - - default: - printf("Unknown option %c\n", (char)opt); - exit(1); } } + if (log_stdout && Fork) { printf("Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n"); - usage(); + poptPrintUsage(pc, stderr, 0); exit(1); } @@ -950,6 +917,7 @@ static void usage(void) DEBUG(0, ("unable to initialise messaging system\n")); exit(1); } + poptFreeContext(pc); register_msg_pool_usage(); message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info); -- cgit From b5762d9937ac919e50e57d97eb26cbb1d3ae2757 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 23 Mar 2003 14:19:13 +0000 Subject: Implement abartlet's suggestion to add attribs to ldap if they are 'SET' when adding the account. I really don't like passing flags down to inner routines and complicated if/else conditions, but this time he might be right. ;-) Volker (This used to be commit 80d2578108da14f60133df3a308b867beb27e920) --- source3/passdb/pdb_ldap.c | 54 ++++++++++++++++++++++++++--------------------- source3/utils/pdbedit.c | 6 ------ 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index f4d04561c1..a7a168fe64 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -1273,6 +1273,11 @@ static BOOL init_sam_from_ldap (struct ldapsam_privates *ldap_state, return True; } +/********************************************************************** + An LDAP modification is needed in two cases: + * If we are updating the record AND the attribute is CHANGED. + * If we are adding the record AND it is SET or CHANGED (ie not default) +*********************************************************************/ static BOOL need_ldap_mod(BOOL pdb_add, const SAM_ACCOUNT * sampass, enum pdb_elements element) { if (pdb_add) { return (!IS_SAM_DEFAULT(sampass, element)); @@ -1287,13 +1292,13 @@ static BOOL need_ldap_mod(BOOL pdb_add, const SAM_ACCOUNT * sampass, enum pdb_el *********************************************************************/ static void make_ldap_mod(LDAP *ldap_struct, LDAPMessage *existing, LDAPMod ***mods, - const SAM_ACCOUNT *sampass, + const SAM_ACCOUNT *sampass, BOOL pdb_add, enum pdb_elements element, const char *attribute, const char *newval) { char **values = NULL; - if (!IS_SAM_CHANGED(sampass, element)) { + if (!need_ldap_mod(pdb_add, sampass, element)) { return; } @@ -1342,7 +1347,8 @@ Initialize SAM_ACCOUNT from an LDAP query *********************************************************************/ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, LDAPMessage *existing, - LDAPMod *** mods, const SAM_ACCOUNT * sampass) + LDAPMod *** mods, const SAM_ACCOUNT * sampass, + BOOL pdb_add) { pstring temp; uint32 rid; @@ -1358,7 +1364,7 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, * took out adding "objectclass: sambaAccount" * do this on a per-mod basis */ - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_USERNAME, "uid", pdb_get_username(sampass)); DEBUG(2, ("Setting entry for user: %s\n", pdb_get_username(sampass))); @@ -1386,7 +1392,7 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, } slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_USERSID, "rid", temp); @@ -1406,7 +1412,7 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, } slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_GROUPSID, "primaryGroupID", temp); /* displayName, cn, and gecos should all be the same @@ -1417,55 +1423,55 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, * it does not exist. */ - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_FULLNAME, "displayName", pdb_get_fullname(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_ACCTDESC, "description", pdb_get_acct_desc(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_WORKSTATIONS, "userWorkstations", pdb_get_workstations(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_SMBHOME, "smbHome", pdb_get_homedir(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_DRIVE, "homeDrive", pdb_get_dir_drive(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_LOGONSCRIPT, "scriptPath", pdb_get_logon_script(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_PROFILE, "profilePath", pdb_get_profile_path(sampass)); slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logon_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_LOGONTIME, "logonTime", temp); slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logoff_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_LOGOFFTIME, "logoffTime", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_kickoff_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_KICKOFFTIME, "kickoffTime", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_can_change_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_CANCHANGETIME, "pwdCanChange", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_must_change_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_MUSTCHANGETIME, "pwdMustChange", temp); if ((pdb_get_acct_ctrl(sampass)&(ACB_WSTRUST|ACB_SVRTRUST|ACB_DOMTRUST))|| @@ -1473,22 +1479,22 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, pdb_sethexpwd (temp, pdb_get_lanman_passwd(sampass), pdb_get_acct_ctrl(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_LMPASSWD, "lmPassword", temp); pdb_sethexpwd (temp, pdb_get_nt_passwd(sampass), pdb_get_acct_ctrl(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_NTPASSWD, "ntPassword", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_last_set_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_PASSLASTSET, "pwdLastSet", temp); } /* FIXME: Hours stuff goes in LDAP */ - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, PDB_ACCTCTRL, "acctFlags", pdb_encode_acct_ctrl (pdb_get_acct_ctrl(sampass), NEW_PW_FORMAT_SPACE_PADDED_LEN)); @@ -1961,7 +1967,7 @@ static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_A entry = ldap_first_entry(ldap_state->ldap_struct, result); dn = ldap_get_dn(ldap_state->ldap_struct, entry); - if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd)) { + if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd, False)) { DEBUG(0, ("ldapsam_update_sam_account: init_ldap_from_sam failed!\n")); ldap_msgfree(result); return NT_STATUS_UNSUCCESSFUL; @@ -2060,7 +2066,7 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCO } } - if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd)) { + if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd, True)) { DEBUG(0, ("ldapsam_add_sam_account: init_ldap_from_sam failed!\n")); ldap_msgfree(result); ldap_mods_free(mods, 1); diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 3dfc6206b4..f373adcb0a 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -69,12 +69,6 @@ static int export_database (struct pdb_context *in, struct pdb_context *out) { } while (NT_STATUS_IS_OK(in->pdb_getsampwent(in, user))) { - int i; - - for (i=0; ipdb_add_sam_account(out, user); if (!NT_STATUS_IS_OK(pdb_reset_sam(user))){ fprintf(stderr, "Can't reset SAM_ACCOUNT!\n"); -- cgit From 223828642548c7e25f6189e274aa1edcdfe30c4f Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 24 Mar 2003 06:31:49 +0000 Subject: Started working on python routines to add and delete domain users. Unfortunately users get created with the ACB mask set to disabled and must change password. The set_user_info2 call required to fix this doesn't quite work yet... (This used to be commit 55a341a367a7d1b18ae7ef04678479eb74b68ea3) --- source3/python/py_samr.c | 471 +++++++++++++++++++++++++++++------------- source3/python/py_samr.h | 5 + source3/python/py_samr_conv.c | 73 +++++++ source3/python/setup.py | 1 + 4 files changed, 404 insertions(+), 146 deletions(-) (limited to 'source3') diff --git a/source3/python/py_samr.c b/source3/python/py_samr.c index 182671d047..57acd74bed 100644 --- a/source3/python/py_samr.c +++ b/source3/python/py_samr.c @@ -31,6 +31,272 @@ PyObject *samr_ntstatus; /* This exception is raised when a RPC call returns a status code other than NT_STATUS_OK */ +/* SAMR group handle object */ + +static void py_samr_group_hnd_dealloc(PyObject* self) +{ + PyObject_Del(self); +} + +static PyMethodDef samr_group_methods[] = { + { NULL } +}; + +static PyObject *py_samr_group_hnd_getattr(PyObject *self, char *attrname) +{ + return Py_FindMethod(samr_group_methods, self, attrname); +} + +PyTypeObject samr_group_hnd_type = { + PyObject_HEAD_INIT(NULL) + 0, + "SAMR Group Handle", + sizeof(samr_group_hnd_object), + 0, + py_samr_group_hnd_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + py_samr_group_hnd_getattr, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ +}; + +PyObject *new_samr_group_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *pol) +{ + samr_group_hnd_object *o; + + o = PyObject_New(samr_group_hnd_object, &samr_group_hnd_type); + + o->cli = cli; + o->mem_ctx = mem_ctx; + memcpy(&o->group_pol, pol, sizeof(POLICY_HND)); + + return (PyObject*)o; +} + +/* Alias handle object */ + +static void py_samr_alias_hnd_dealloc(PyObject* self) +{ + PyObject_Del(self); +} + +static PyMethodDef samr_alias_methods[] = { + { NULL } +}; + +static PyObject *py_samr_alias_hnd_getattr(PyObject *self, char *attrname) +{ + return Py_FindMethod(samr_alias_methods, self, attrname); +} + +PyTypeObject samr_alias_hnd_type = { + PyObject_HEAD_INIT(NULL) + 0, + "SAMR Alias Handle", + sizeof(samr_alias_hnd_object), + 0, + py_samr_alias_hnd_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + py_samr_alias_hnd_getattr, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ +}; + +PyObject *new_samr_alias_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *pol) +{ + samr_alias_hnd_object *o; + + o = PyObject_New(samr_alias_hnd_object, &samr_alias_hnd_type); + + o->cli = cli; + o->mem_ctx = mem_ctx; + memcpy(&o->alias_pol, pol, sizeof(POLICY_HND)); + + return (PyObject*)o; +} + +/* SAMR user handle object */ + +static void py_samr_user_hnd_dealloc(PyObject* self) +{ + PyObject_Del(self); +} + +static PyObject *samr_set_user_info2(PyObject *self, PyObject *args, + PyObject *kw) +{ + samr_user_hnd_object *user_hnd = (samr_user_hnd_object *)self; + static char *kwlist[] = { "dict", NULL }; + PyObject *info, *result = NULL; + SAM_USERINFO_CTR ctr; + TALLOC_CTX *mem_ctx; + uchar sess_key[16]; + NTSTATUS ntstatus; + int level; + union { + SAM_USER_INFO_10 id10; + SAM_USER_INFO_21 id21; + } pinfo; + + if (!PyArg_ParseTupleAndKeywords( + args, kw, "O!", kwlist, &PyDict_Type, &info)) + return NULL; + + if (!get_level_value(info, &level)) { + PyErr_SetString(samr_error, "invalid info level"); + return NULL; + } + + ZERO_STRUCT(ctr); + + ctr.switch_value = level; + + switch(level) { + case 0x10: + ctr.info.id10 = &pinfo.id10; + + if (!py_to_SAM_USER_INFO_10(ctr.info.id10, info)) { + PyErr_SetString( + samr_error, "error converting user info"); + goto done; + } + + break; + case 21: + ctr.info.id21 = &pinfo.id21; + + if (!py_to_SAM_USER_INFO_21(ctr.info.id21, info)) { + PyErr_SetString( + samr_error, "error converting user info"); + goto done; + } + + break; + default: + PyErr_SetString(samr_error, "unsupported info level"); + goto done; + } + + /* Call RPC function */ + + if (!(mem_ctx = talloc_init("samr_set_user_info2"))) { + PyErr_SetString( + samr_error, "unable to init talloc context\n"); + goto done; + } + + ntstatus = cli_samr_set_userinfo2( + user_hnd->cli, mem_ctx, &user_hnd->user_pol, level, + sess_key, &ctr); + + talloc_destroy(mem_ctx); + + if (!NT_STATUS_IS_OK(ntstatus)) { + PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus)); + goto done; + } + + Py_INCREF(Py_None); + result = Py_None; + +done: + return result; +} + +static PyObject *samr_delete_dom_user(PyObject *self, PyObject *args, + PyObject *kw) +{ + samr_user_hnd_object *user_hnd = (samr_user_hnd_object *)self; + static char *kwlist[] = { NULL }; + NTSTATUS ntstatus; + TALLOC_CTX *mem_ctx; + PyObject *result = NULL; + + if (!PyArg_ParseTupleAndKeywords( + args, kw, "", kwlist)) + return NULL; + + if (!(mem_ctx = talloc_init("samr_delete_dom_user"))) { + PyErr_SetString(samr_error, "unable to init talloc context"); + return NULL; + } + + ntstatus = cli_samr_delete_dom_user( + user_hnd->cli, mem_ctx, &user_hnd->user_pol); + + if (!NT_STATUS_IS_OK(ntstatus)) { + PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus)); + goto done; + } + + Py_INCREF(Py_None); + result = Py_None; + +done: + talloc_destroy(mem_ctx); + + return result; +} + +static PyMethodDef samr_user_methods[] = { + { "delete_domain_user", (PyCFunction)samr_delete_dom_user, + METH_VARARGS | METH_KEYWORDS, + "Delete domain user." }, + { "set_user_info2", (PyCFunction)samr_set_user_info2, + METH_VARARGS | METH_KEYWORDS, + "Set user info 2" }, + { NULL } +}; + +static PyObject *py_samr_user_hnd_getattr(PyObject *self, char *attrname) +{ + return Py_FindMethod(samr_user_methods, self, attrname); +} + +PyTypeObject samr_user_hnd_type = { + PyObject_HEAD_INIT(NULL) + 0, + "SAMR User Handle", + sizeof(samr_user_hnd_object), + 0, + py_samr_user_hnd_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + py_samr_user_hnd_getattr, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ +}; + +PyObject *new_samr_user_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, + POLICY_HND *pol) +{ + samr_user_hnd_object *o; + + o = PyObject_New(samr_user_hnd_object, &samr_user_hnd_type); + + o->cli = cli; + o->mem_ctx = mem_ctx; + memcpy(&o->user_pol, pol, sizeof(POLICY_HND)); + + return (PyObject*)o; +} + /* SAMR connect handle object */ static void py_samr_connect_hnd_dealloc(PyObject* self) @@ -163,8 +429,7 @@ static PyObject *samr_enum_dom_groups(PyObject *self, PyObject *args, NTSTATUS result; PyObject *py_result = NULL; - if (!PyArg_ParseTupleAndKeywords( - args, kw, "", kwlist)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "", kwlist)) return NULL; if (!(mem_ctx = talloc_init("samr_enum_dom_groups"))) { @@ -191,9 +456,52 @@ static PyObject *samr_enum_dom_groups(PyObject *self, PyObject *args, return py_result; } +static PyObject *samr_create_dom_user(PyObject *self, PyObject *args, + PyObject *kw) +{ + samr_domain_hnd_object *domain_hnd = (samr_domain_hnd_object *)self; + static char *kwlist[] = { "account_name", "acb_info", NULL }; + char *account_name; + NTSTATUS ntstatus; + uint32 unknown = 0xe005000b; /* Access mask? */ + uint32 user_rid; + PyObject *result = NULL; + TALLOC_CTX *mem_ctx; + uint16 acb_info = ACB_NORMAL; + POLICY_HND user_pol; + + if (!PyArg_ParseTupleAndKeywords( + args, kw, "s|i", kwlist, &account_name, &acb_info)) + return NULL; + + if (!(mem_ctx = talloc_init("samr_create_dom_user"))) { + PyErr_SetString(samr_error, "unable to init talloc context"); + return NULL; + } + + ntstatus = cli_samr_create_dom_user( + domain_hnd->cli, mem_ctx, &domain_hnd->domain_pol, + account_name, acb_info, unknown, &user_pol, &user_rid); + + if (!NT_STATUS_IS_OK(ntstatus)) { + PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus)); + talloc_destroy(mem_ctx); + goto done; + } + + result = new_samr_user_hnd_object( + domain_hnd->cli, mem_ctx, &user_pol); + +done: + + return result; +} + static PyMethodDef samr_domain_methods[] = { { "enum_domain_groups", (PyCFunction)samr_enum_dom_groups, METH_VARARGS | METH_KEYWORDS, "Enumerate domain groups" }, + { "create_domain_user", (PyCFunction)samr_create_dom_user, + METH_VARARGS | METH_KEYWORDS, "Create domain user" }, { NULL } }; @@ -220,150 +528,6 @@ PyTypeObject samr_domain_hnd_type = { 0, /*tp_hash */ }; -/* SAMR user handle object */ - -static void py_samr_user_hnd_dealloc(PyObject* self) -{ - PyObject_Del(self); -} - -static PyMethodDef samr_user_methods[] = { - { NULL } -}; - -static PyObject *py_samr_user_hnd_getattr(PyObject *self, char *attrname) -{ - return Py_FindMethod(samr_user_methods, self, attrname); -} - -PyTypeObject samr_user_hnd_type = { - PyObject_HEAD_INIT(NULL) - 0, - "SAMR User Handle", - sizeof(samr_user_hnd_object), - 0, - py_samr_user_hnd_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - py_samr_user_hnd_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -PyObject *new_samr_user_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol) -{ - samr_user_hnd_object *o; - - o = PyObject_New(samr_user_hnd_object, &samr_user_hnd_type); - - o->cli = cli; - o->mem_ctx = mem_ctx; - memcpy(&o->user_pol, pol, sizeof(POLICY_HND)); - - return (PyObject*)o; -} - -/* SAMR group handle object */ - -static void py_samr_group_hnd_dealloc(PyObject* self) -{ - PyObject_Del(self); -} - -static PyMethodDef samr_group_methods[] = { - { NULL } -}; - -static PyObject *py_samr_group_hnd_getattr(PyObject *self, char *attrname) -{ - return Py_FindMethod(samr_group_methods, self, attrname); -} - -PyTypeObject samr_group_hnd_type = { - PyObject_HEAD_INIT(NULL) - 0, - "SAMR Group Handle", - sizeof(samr_group_hnd_object), - 0, - py_samr_group_hnd_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - py_samr_group_hnd_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -PyObject *new_samr_group_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol) -{ - samr_group_hnd_object *o; - - o = PyObject_New(samr_group_hnd_object, &samr_group_hnd_type); - - o->cli = cli; - o->mem_ctx = mem_ctx; - memcpy(&o->group_pol, pol, sizeof(POLICY_HND)); - - return (PyObject*)o; -} - -/* Alias handle object */ - -static void py_samr_alias_hnd_dealloc(PyObject* self) -{ - PyObject_Del(self); -} - -static PyMethodDef samr_alias_methods[] = { - { NULL } -}; - -static PyObject *py_samr_alias_hnd_getattr(PyObject *self, char *attrname) -{ - return Py_FindMethod(samr_alias_methods, self, attrname); -} - -PyTypeObject samr_alias_hnd_type = { - PyObject_HEAD_INIT(NULL) - 0, - "SAMR Alias Handle", - sizeof(samr_alias_hnd_object), - 0, - py_samr_alias_hnd_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - py_samr_alias_hnd_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash */ -}; - -PyObject *new_samr_alias_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol) -{ - samr_alias_hnd_object *o; - - o = PyObject_New(samr_alias_hnd_object, &samr_alias_hnd_type); - - o->cli = cli; - o->mem_ctx = mem_ctx; - memcpy(&o->alias_pol, pol, sizeof(POLICY_HND)); - - return (PyObject*)o; -} - static PyObject *samr_connect(PyObject *self, PyObject *args, PyObject *kw) { static char *kwlist[] = { "server", "creds", "access", NULL }; @@ -446,6 +610,21 @@ static struct const_vals { char *name; uint32 value; } module_const_vals[] = { + + /* Account control bits */ + + { "ACB_DISABLED", 0x0001 }, + { "ACB_HOMDIRREQ", 0x0002 }, + { "ACB_PWNOTREQ", 0x0004 }, + { "ACB_TEMPDUP", 0x0008 }, + { "ACB_NORMAL", 0x0010 }, + { "ACB_MNS", 0x0020 }, + { "ACB_DOMTRUST", 0x0040 }, + { "ACB_WSTRUST", 0x0080 }, + { "ACB_SVRTRUST", 0x0100 }, + { "ACB_PWNOEXP", 0x0200 }, + { "ACB_AUTOLOCK", 0x0400 }, + { NULL } }; diff --git a/source3/python/py_samr.h b/source3/python/py_samr.h index 3292eb97ec..4d2b0675b4 100644 --- a/source3/python/py_samr.h +++ b/source3/python/py_samr.h @@ -78,4 +78,9 @@ extern PyObject *samr_error; /* The following definitions are from py_samr_conv.c */ BOOL py_from_acct_info(PyObject **array, struct acct_info *info, int num_accts); +BOOL py_from_SAM_USER_INFO_10(PyObject **dict, SAM_USER_INFO_10 *info); +BOOL py_to_SAM_USER_INFO_10(SAM_USER_INFO_10 *info, PyObject *dict); +BOOL py_from_SAM_USER_INFO_21(PyObject **dict, SAM_USER_INFO_21 *info); +BOOL py_to_SAM_USER_INFO_21(SAM_USER_INFO_21 *info, PyObject *dict); + #endif /* _PY_SAMR_H */ diff --git a/source3/python/py_samr_conv.c b/source3/python/py_samr_conv.c index fdf71641e0..7523ee7dfc 100644 --- a/source3/python/py_samr_conv.c +++ b/source3/python/py_samr_conv.c @@ -21,6 +21,79 @@ #include "python/py_samr.h" #include "python/py_conv.h" +/* + * Convert between SAM_USER_INFO_10 and Python + */ + +struct pyconv py_SAM_USER_INFO_10[] = { + { "acb_info", PY_UINT32, offsetof(SAM_USER_INFO_10, acb_info) }, + { NULL } +}; + +BOOL py_from_SAM_USER_INFO_10(PyObject **dict, SAM_USER_INFO_10 *info) +{ + *dict = from_struct(info, py_SAM_USER_INFO_10); + PyDict_SetItemString(*dict, "level", PyInt_FromLong(0x10)); + return True; +} + +BOOL py_to_SAM_USER_INFO_10(SAM_USER_INFO_10 *info, PyObject *dict) +{ + PyObject *obj, *dict_copy = PyDict_Copy(dict); + BOOL result = False; + + if (!(obj = PyDict_GetItemString(dict_copy, "level")) || + !PyInt_Check(obj)) + goto done; + + PyDict_DelItemString(dict_copy, "level"); + + if (!to_struct(info, dict_copy, py_SAM_USER_INFO_10)) + goto done; + + result = True; + +done: + Py_DECREF(dict_copy); + return result; +} + +/* + * Convert between SAM_USER_INFO_21 and Python + */ + +struct pyconv py_SAM_USER_INFO_21[] = { + { NULL } +}; + +BOOL py_from_SAM_USER_INFO_21(PyObject **dict, SAM_USER_INFO_21 *info) +{ + *dict = from_struct(info, py_SAM_USER_INFO_21); + PyDict_SetItemString(*dict, "level", PyInt_FromLong(21)); + return True; +} + +BOOL py_to_SAM_USER_INFO_21(SAM_USER_INFO_21 *info, PyObject *dict) +{ + PyObject *obj, *dict_copy = PyDict_Copy(dict); + BOOL result = False; + + if (!(obj = PyDict_GetItemString(dict_copy, "level")) || + !PyInt_Check(obj)) + goto done; + + PyDict_DelItemString(dict_copy, "level"); + + if (!to_struct(info, dict_copy, py_SAM_USER_INFO_21)) + goto done; + + result = True; + +done: + Py_DECREF(dict_copy); + return result; +} + /* * Convert between acct_info and Python */ diff --git a/source3/python/setup.py b/source3/python/setup.py index 8bc8868a70..6569331031 100755 --- a/source3/python/setup.py +++ b/source3/python/setup.py @@ -116,6 +116,7 @@ setup( Extension(name = "samr", sources = [samba_srcdir + "python/py_samr.c", + samba_srcdir + "python/py_conv.c", samba_srcdir + "python/py_samr_conv.c", samba_srcdir + "python/py_common.c"], libraries = lib_list, -- cgit From 11e9de855ca84af8d34a5f6459f304fcfa72dca3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 11:25:34 +0000 Subject: Patch from metze to generalise POPT_COMMON_SAMBA, with some minor changes (This used to be commit 2ddfed298d7f0b6e690275725a39c3ef107077ae) --- source3/client/client.c | 16 ++--- source3/include/popt_common.h | 11 +-- source3/lib/popt_common.c | 95 ++++++++++--------------- source3/nmbd/nmbd.c | 5 -- source3/nsswitch/wbinfo.c | 4 +- source3/nsswitch/winbindd.c | 7 +- source3/rpcclient/rpcclient.c | 156 +++--------------------------------------- source3/smbd/server.c | 4 -- source3/torture/samtest.c | 14 ++-- source3/torture/vfstest.c | 44 +++--------- source3/utils/net.c | 3 - source3/utils/nmblookup.c | 3 - source3/utils/ntlm_auth.c | 10 ++- source3/utils/pdbedit.c | 4 +- source3/utils/smbcacls.c | 45 +++--------- source3/utils/smbtree.c | 8 +-- source3/utils/status.c | 6 +- source3/utils/testparm.c | 4 +- source3/web/swat.c | 5 +- source3/wrepld/server.c | 8 +-- 20 files changed, 95 insertions(+), 357 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 9fb843cfba..8d6730cdc6 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2589,15 +2589,7 @@ static void remember_query_host(const char *arg, int rc = 0; struct poptOption long_options[] = { POPT_AUTOHELP - POPT_COMMON_SAMBA - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_netbios_name }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_scope }, - POPT_CREDENTIALS + { "name-resolve", 'R', POPT_ARG_STRING, &new_name_resolve_order, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" }, { "message", 'M', POPT_ARG_STRING, NULL, 'M', "Send message", "HOST" }, { "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" }, @@ -2610,7 +2602,9 @@ static void remember_query_host(const char *arg, { "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" }, { "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" }, { "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" }, - { 0, 0, 0, 0 } + POPT_COMMON_SAMBA + POPT_CREDENTIALS + POPT_TABLEEND }; @@ -2720,7 +2714,7 @@ static void remember_query_host(const char *arg, pstrcpy(username, cmdline_auth_info.username); pstrcpy(password, cmdline_auth_info.password); - pstrcpy(workgroup, cmdline_auth_info.workgroup); + pstrcpy(workgroup, lp_workgroup()); use_kerberos = cmdline_auth_info.use_kerberos; got_pass = cmdline_auth_info.got_pass; diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h index 9354e8734d..7cdbc98862 100644 --- a/source3/include/popt_common.h +++ b/source3/include/popt_common.h @@ -22,22 +22,15 @@ #define _POPT_COMMON_H /* Common popt structures */ -extern struct poptOption popt_common_debug[]; -extern struct poptOption popt_common_configfile[]; -extern struct poptOption popt_common_socket_options[]; -extern struct poptOption popt_common_version[]; -extern struct poptOption popt_common_netbios_name[]; -extern struct poptOption popt_common_log_base[]; +extern struct poptOption popt_common_samba[]; extern struct poptOption popt_common_credentials[]; -extern struct poptOption popt_common_scope[]; -#define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version, 0, "Common samba options:", NULL }, +#define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_samba, 0, "Common samba options:", NULL }, #define POPT_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL }, struct user_auth_info { pstring username; pstring password; - pstring workgroup; BOOL got_pass; BOOL use_kerberos; }; diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 3c9a87b361..06ba4fc898 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -29,6 +29,7 @@ * -V,--version * -l,--log-base * -n,--netbios-name + * -W,--workgroup * -i,--scope */ @@ -102,49 +103,29 @@ static void popt_common_callback(poptContext con, set_global_scope(arg); } break; + + case 'W': + if (arg) { + set_global_myworkgroup(arg); + } + break; } } -struct poptOption popt_common_debug[] = { +struct poptOption popt_common_samba[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, - { 0 } -}; - -struct poptOption popt_common_scope[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, - { 0 } -}; - -struct poptOption popt_common_configfile[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file" }, - { 0 } -}; - -struct poptOption popt_common_socket_options[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - {"socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use" }, - { 0 } -}; - -struct poptOption popt_common_version[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - {"version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, - { 0 } -}; - -struct poptOption popt_common_netbios_name[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - {"netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name"}, - { 0 } -}; - -struct poptOption popt_common_log_base[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, - { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files"}, - { 0 } + { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", + "CONFIGFILE" }, + { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", + "SOCKETOPTIONS" }, + { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, + { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", + "LOGFILEBASE" }, + { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, + { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, + { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, + POPT_TABLEEND }; /**************************************************************************** @@ -255,7 +236,7 @@ static void get_credentials_file(const char *file, struct user_auth_info *info) else if (strwicmp("username", param) == 0) pstrcpy(info->username, val); else if (strwicmp("domain", param) == 0) - pstrcpy(info->workgroup,val); + set_global_myworkgroup(val); memset(buf, 0, sizeof(buf)); } x_fclose(auth); @@ -263,7 +244,6 @@ static void get_credentials_file(const char *file, struct user_auth_info *info) /* Handle command line options: * -U,--user - * -W,--workgroup * -A,--authentication-file * -k,--use-kerberos * -N,--no-pass @@ -327,30 +307,25 @@ static void popt_common_credentials_callback(poptContext con, get_credentials_file(arg, &cmdline_auth_info); break; - case 'W': - pstrcpy(cmdline_auth_info.workgroup,arg); - break; - - case 'k': + case 'k': #ifndef HAVE_KRB5 - d_printf("No kerberos support compiled in\n"); - exit(1); + d_printf("No kerberos support compiled in\n"); + exit(1); #else - cmdline_auth_info.got_pass = True; + cmdline_auth_info.use_kerberos = True; + cmdline_auth_info.got_pass = True; #endif - - break; - } + break; } +} - struct poptOption popt_common_credentials[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, - { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, - { "no-pass", 'N', POPT_ARG_VAL, &cmdline_auth_info.got_pass, True, "Don't ask for a password" }, - { "kerberos", 'k', POPT_ARG_VAL, &cmdline_auth_info.use_kerberos, True, "Use kerberos (active directory) authentication" }, - { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, - { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, - { 0 } - }; +struct poptOption popt_common_credentials[] = { + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, + { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, + { "no-pass", 'N', POPT_ARG_NONE, &cmdline_auth_info.got_pass, True, "Don't ask for a password" }, + { "kerberos", 'k', POPT_ARG_NONE, &cmdline_auth_info.use_kerberos, True, "Use kerberos (active directory) authentication" }, + { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, + POPT_TABLEEND +}; diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index a34593557e..d013b79d3e 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -601,11 +601,6 @@ static BOOL open_sockets(BOOL isdaemon, int port) {"hosts", 'H', POPT_ARG_STRING, dyn_LMHOSTSFILE, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, POPT_COMMON_SAMBA - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_netbios_name }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base }, { NULL } }; pstring logfile; diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 4f621e7008..fe11cd6528 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -711,8 +711,8 @@ int main(int argc, char **argv) { "set-auth-user", 'A', POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", "user%password" }, { "get-auth-user", 0, POPT_ARG_NONE, NULL, OPT_GET_AUTH_USER, "Retrieve user and password used by winbindd (root only)", NULL }, { "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if it is alive" }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { 0, 0, 0, 0 } + POPT_COMMON_SAMBA + POPT_TABLEEND }; /* Samba client initialisation */ diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index c9d6808316..cd72a4f572 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -814,16 +814,13 @@ int main(int argc, char **argv) static BOOL log_stdout = False; struct poptOption long_options[] = { POPT_AUTOHELP - POPT_COMMON_SAMBA - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" }, { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" }, { "dual-daemon", 'B', POPT_ARG_VAL, &opt_dual_daemon, True, "Dual daemon mode" }, { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, False, "Disable caching" }, - - { 0, 0, 0, 0 } + POPT_COMMON_SAMBA + POPT_TABLEEND }; poptContext pc; int opt; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 2338d72f19..97a944dbf9 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -97,70 +97,6 @@ static char **completion_fn(char *text, int start, int end) return matches; } -/*********************************************************************** - * read in username/password credentials from a file - */ -static void read_authfile ( - char *filename, - char* username, - char* password, - char* domain -) -{ - FILE *auth; - fstring buf; - uint16 len = 0; - char *ptr, *val, *param; - - if ((auth=sys_fopen(filename, "r")) == NULL) - { - printf ("ERROR: Unable to open credentials file!\n"); - return; - } - - while (!feof(auth)) - { - /* get a line from the file */ - if (!fgets (buf, sizeof(buf), auth)) - continue; - - len = strlen(buf); - - /* skip empty lines */ - if ((len) && (buf[len-1]=='\n')) - { - buf[len-1] = '\0'; - len--; - } - if (len == 0) - continue; - - /* break up the line into parameter & value. - will need to eat a little whitespace possibly */ - param = buf; - if (!(ptr = strchr_m(buf, '='))) - continue; - val = ptr+1; - *ptr = '\0'; - - /* eat leading white space */ - while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) - val++; - - if (strwicmp("password", param) == 0) - fstrcpy (password, val); - else if (strwicmp("username", param) == 0) - fstrcpy (username, val); - else if (strwicmp("domain", param) == 0) - fstrcpy (domain, val); - - memset(buf, 0, sizeof(buf)); - } - fclose(auth); - - return; -} - static char* next_command (char** cmdstr) { static pstring command; @@ -181,28 +117,6 @@ static char* next_command (char** cmdstr) return command; } - -/** - * Find default username from environment variables. - * - * @param username fstring to receive username; not touched if none is - * known. - **/ -static void get_username (char *username) -{ - if (getenv("USER")) - fstrcpy(username,getenv("USER")); - - if (*username == 0 && getenv("LOGNAME")) - fstrcpy(username,getenv("LOGNAME")); - - if (*username == 0) { - fstrcpy(username,"GUEST"); - } - - return; -} - /* Fetch the SID for this computer */ static void fetch_machine_sid(struct cli_state *cli) @@ -575,21 +489,12 @@ out_free: int main(int argc, char *argv[]) { - static int got_pass = 0; BOOL interactive = True; int opt; - static char *cmdstr = ""; + static char *cmdstr = NULL; const char *server; struct cli_state *cli; - fstring password="", - username="", - domain=""; - static char *opt_authfile=NULL, - *opt_username=NULL, - *opt_domain=NULL, - *opt_logfile=NULL, - *opt_ipaddr=NULL; - pstring logfile; + static char *opt_ipaddr=NULL; struct cmd_set **cmd_set; struct in_addr server_ip; NTSTATUS nt_status; @@ -599,17 +504,11 @@ out_free: poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP - {"authfile", 'A', POPT_ARG_STRING, &opt_authfile, 'A', "File containing user credentials", "AUTHFILE"}, - {"nopass", 'N', POPT_ARG_NONE, &got_pass, 'N', "Don't ask for a password"}, - {"user", 'U', POPT_ARG_STRING, &opt_username, 'U', "Set the network username", "USER"}, - {"workgroup", 'W', POPT_ARG_STRING, &opt_domain, 'W', "Set the domain name for user account", "DOMAIN"}, {"command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated cmds", "COMMANDS"}, - {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l', "Logfile to use instead of stdout", "LOGFILE" }, {"dest-ip", 'I', POPT_ARG_STRING, &opt_ipaddr, 'I', "Specify destination IP address", "IP"}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { NULL } + POPT_COMMON_SAMBA + POPT_CREDENTIALS + POPT_TABLEEND }; ZERO_STRUCT(server_ip); @@ -628,43 +527,13 @@ out_free: while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { - case 'A': - /* only get the username, password, and domain from the file */ - read_authfile (opt_authfile, username, password, domain); - if (strlen (password)) - got_pass = 1; - break; - - case 'l': - slprintf(logfile, sizeof(logfile) - 1, "%s.client", - opt_logfile); - lp_set_logfile(logfile); - interactive = False; - break; - - case 'U': { - char *lp; - fstrcpy(username,opt_username); - - if ((lp=strchr_m(username,'%'))) { - *lp = 0; - fstrcpy(password,lp+1); - got_pass = 1; - memset(strchr_m(opt_username,'%') + 1, 'X', - strlen(password)); - } - break; - } case 'I': if ( (server_ip.s_addr=inet_addr(opt_ipaddr)) == INADDR_NONE ) { fprintf(stderr, "%s not a valid IP address\n", opt_ipaddr); return 1; } - case 'W': - fstrcpy(domain, opt_domain); - break; } } @@ -701,28 +570,25 @@ out_free: * from stdin if necessary */ - if (!got_pass) { + if (!cmdline_auth_info.got_pass) { char *pass = getpass("Password:"); if (pass) { - fstrcpy(password, pass); + pstrcpy(cmdline_auth_info.password, pass); } } - if (!strlen(username) && !got_pass) - get_username(username); - nt_status = cli_full_connection(&cli, global_myname(), server, opt_ipaddr ? &server_ip : NULL, 0, "IPC$", "IPC", - username, domain, - password, 0, NULL); + cmdline_auth_info.username, lp_workgroup(), + cmdline_auth_info.password, 0, NULL); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(0,("Cannot connect to server. Error was %s\n", nt_errstr(nt_status))); return 1; } - memset(password,'X',sizeof(password)); + memset(cmdline_auth_info.password,'X',sizeof(cmdline_auth_info.password)); /* Load command lists */ @@ -737,7 +603,7 @@ out_free: fetch_machine_sid(cli); /* Do anything specified with -c */ - if (cmdstr[0]) { + if (cmdstr && cmdstr[0]) { char *cmd; char *p = cmdstr; diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 627fad1572..715e916263 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -670,10 +670,6 @@ static BOOL init_structs(void ) {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, POPT_COMMON_SAMBA - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base}, { NULL } }; diff --git a/source3/torture/samtest.c b/source3/torture/samtest.c index 0de2e5d288..fd5f75a664 100644 --- a/source3/torture/samtest.c +++ b/source3/torture/samtest.c @@ -353,10 +353,7 @@ int main(int argc, char *argv[]) { BOOL interactive = True; int opt; - static char *cmdstr = ""; - static char *opt_logfile=NULL; - static char *config_file = dyn_CONFIGFILE; - pstring logfile; + static char *cmdstr = NULL; struct cmd_set **cmd_set; struct samtest_state st; @@ -365,12 +362,9 @@ int main(int argc, char *argv[]) poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, {"command", 'e', POPT_ARG_STRING, &cmdstr, 'e', "Execute semicolon seperated cmds"}, - {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l', "Logfile to use instead of stdout"}, - {"configfile", 'c', POPT_ARG_STRING, &config_file, 0,"use different configuration file",NULL}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { 0, 0, 0, 0} + POPT_COMMON_SAMBA + POPT_TABLEEND }; ZERO_STRUCT(st); @@ -419,7 +413,7 @@ int main(int argc, char *argv[]) } /* Do anything specified with -c */ - if (cmdstr[0]) { + if (cmdstr && cmdstr[0]) { char *cmd; char *p = cmdstr; diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c index 04f31656d3..3b28a3c496 100644 --- a/source3/torture/vfstest.c +++ b/source3/torture/vfstest.c @@ -4,7 +4,7 @@ Copyright (C) Simo Sorce 2002 Copyright (C) Eric Lorimer 2002 - Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Jelmer Vernooij 2002,2003 Most of this code was ripped off of rpcclient. Copyright (C) Tim Potter 2000-2001 @@ -474,17 +474,11 @@ BOOL reload_services(BOOL test) int main(int argc, char *argv[]) { - BOOL interactive = True; - int opt; - static char *cmdstr = ""; - static char *opt_logfile=NULL; - static int opt_debuglevel; - pstring logfile; + static char *cmdstr = NULL; struct cmd_set **cmd_set; - extern BOOL AllowDebugChange; static struct vfs_state vfs; int i; - static const char *filename = ""; + static const char *filename = NULL; /* make sure the vars that get altered (4th field) are in a fixed location or certain compilers complain */ @@ -493,35 +487,17 @@ int main(int argc, char *argv[]) POPT_AUTOHELP {"file", 'f', POPT_ARG_STRING, &filename, 0, }, {"command", 'c', POPT_ARG_STRING, &cmdstr, 0, "Execute specified list of commands" }, - {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l', "Write output to specified logfile" }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { 0, 0, 0, 0} + POPT_COMMON_SAMBA + POPT_TABLEEND }; setlinebuf(stdout); - DEBUGLEVEL = 1; - AllowDebugChange = False; - pc = poptGetContext("vfstest", argc, (const char **) argv, long_options, 0); - while((opt = poptGetNextOpt(pc)) != -1) { - switch (opt) { - case 'l': - slprintf(logfile, sizeof(logfile) - 1, "%s.client", - opt_logfile); - lp_set_logfile(logfile); - interactive = False; - break; - - case 'd': - DEBUGLEVEL = opt_debuglevel; - break; - } - } + while(poptGetNextOpt(pc) != -1); poptFreeContext(pc); @@ -531,9 +507,7 @@ int main(int argc, char *argv[]) /* the following functions are part of the Samba debugging facilities. See lib/debug.c */ - setup_logging("vfstest", interactive); - if (!interactive) - reopen_logs(); + setup_logging("vfstest", True); /* Load command lists */ @@ -556,13 +530,13 @@ int main(int argc, char *argv[]) smbd_vfs_init(vfs.conn); /* Do we have a file input? */ - if (filename[0]) { + if (filename && filename[0]) { process_file(&vfs, filename); return 0; } /* Do anything specified with -c */ - if (cmdstr[0]) { + if (cmdstr && cmdstr[0]) { char *cmd; char *p = cmdstr; diff --git a/source3/utils/net.c b/source3/utils/net.c index 33c125901b..d6945ceefb 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -515,7 +515,6 @@ static struct functable net_func[] = { struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, 0, 'h'}, {"workgroup", 'w', POPT_ARG_STRING, &opt_target_workgroup}, - {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup}, {"user", 'U', POPT_ARG_STRING, &opt_user_name, 'U'}, {"ipaddress", 'I', POPT_ARG_STRING, 0,'I'}, {"port", 'p', POPT_ARG_INT, &opt_port}, @@ -532,8 +531,6 @@ static struct functable net_func[] = { {"timeout", 't', POPT_ARG_INT, &opt_timeout}, {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass}, POPT_COMMON_SAMBA - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, { 0, 0, 0, 0} }; diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 97cea3a7bb..88038fb566 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -203,9 +203,6 @@ int main(int argc,char *argv[]) { "root-port", 'r', POPT_ARG_VAL, &RootPort, True, "Use root port 137 (Win95 only replies to this)" }, { "lookup-by-ip", 'A', POPT_ARG_VAL, &lookup_by_ip, True, "Do a node status on as an IP Address" }, POPT_COMMON_SAMBA - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_scope }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, { 0, 0, 0, 0 } }; diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index ac456769f2..a28bbf9364 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -439,14 +439,13 @@ enum { OPT_NT_KEY }; -int main(int argc, const char **argv) + int main(int argc, const char **argv) { int opt; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP - { "helper-protocol", 0, POPT_ARG_STRING, &helper_protocol, OPT_DOMAIN, "operate as a stdio-based helper", "helper protocol to use"}, { "username", 0, POPT_ARG_STRING, &username, OPT_USERNAME, "username"}, { "domain", 0, POPT_ARG_STRING, &domain, OPT_DOMAIN, "domain name"}, @@ -457,10 +456,9 @@ int main(int argc, const char **argv) { "password", 0, POPT_ARG_STRING, &password, OPT_PASSWORD, "User's plaintext password"}, { "request-lm-key", 0, POPT_ARG_NONE, &request_lm_key, OPT_LM_KEY, "Retreive LM session key"}, { "request-nt-key", 0, POPT_ARG_NONE, &request_nt_key, OPT_NT_KEY, "Retreive NT session key"}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { 0, 0, 0, 0 } + POPT_COMMON_SAMBA + POPT_CREDENTIALS + POPT_TABLEEND }; /* Samba client initialisation */ diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index f373adcb0a..03be2571e5 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -537,9 +537,7 @@ int main (int argc, char **argv) {"value", 'C', POPT_ARG_LONG, &account_policy_value, 'C',"set the account policy to this value", NULL}, {"account-control", 'c', POPT_ARG_STRING, &account_control, 0, "Values of account control", NULL}, POPT_COMMON_SAMBA - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - {0,0,0,0} + POPT_TABLEEND }; setup_logging("pdbedit", True); diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index af5bf09e48..ac15cf1aa0 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -24,11 +24,8 @@ #include "includes.h" -static fstring password; -static pstring username; static pstring owner_username; static fstring server; -static int got_pass; static int test_args = False; static TALLOC_CTX *ctx; @@ -716,19 +713,19 @@ static struct cli_state *connect_one(const char *share) NTSTATUS nt_status; zero_ip(&ip); - if (!got_pass) { + if (!cmdline_auth_info.got_pass) { char *pass = getpass("Password: "); if (pass) { - fstrcpy(password, pass); - got_pass = True; + pstrcpy(cmdline_auth_info.password, pass); + cmdline_auth_info.got_pass = True; } } if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname(), server, &ip, 0, share, "?????", - username, lp_workgroup(), - password, 0, NULL))) { + cmdline_auth_info.username, lp_workgroup(), + cmdline_auth_info.password, 0, NULL))) { return c; } else { DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status))); @@ -743,7 +740,6 @@ static struct cli_state *connect_one(const char *share) { char *share; int opt; - char *p; enum acl_mode mode = SMB_ACL_SET; static char *the_acl = NULL; enum chown_mode change_mode = REQUEST_NONE; @@ -759,12 +755,10 @@ static struct cli_state *connect_one(const char *share) { "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls", "ACLS" }, { "chown", 'C', POPT_ARG_STRING, NULL, 'C', "Change ownership of a file", "USERNAME" }, { "chgrp", 'G', POPT_ARG_STRING, NULL, 'G', "Change group ownership of a file", "GROUPNAME" }, - { "numeric", 'n', POPT_ARG_VAL, &numeric, True, "Don't resolve sids or masks to names" }, - { "test-args", 't', POPT_ARG_VAL, &test_args, True, "Test arguments"}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - {"username", 'U', POPT_ARG_STRING, NULL, 'U', "User to authenticate as", "user%password" }, + { "numeric", 0, POPT_ARG_NONE, &numeric, True, "Don't resolve sids or masks to names" }, + { "test-args", 't', POPT_ARG_NONE, &test_args, True, "Test arguments"}, + POPT_COMMON_SAMBA + POPT_CREDENTIALS { NULL } }; @@ -781,33 +775,12 @@ static struct cli_state *connect_one(const char *share) lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); - if (getenv("USER")) { - pstrcpy(username,getenv("USER")); - - if ((p=strchr_m(username,'%'))) { - *p = 0; - fstrcpy(password,p+1); - got_pass = True; - memset(strchr_m(getenv("USER"), '%') + 1, 'X', - strlen(password)); - } - } pc = poptGetContext("smbcacls", argc, argv, long_options, 0); poptSetOtherOptionHelp(pc, "//server1/share1 filename"); while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { - case 'U': - pstrcpy(username,poptGetOptArg(pc)); - p = strchr_m(username,'%'); - if (p) { - *p = 0; - fstrcpy(password, p+1); - got_pass = 1; - } - break; - case 'S': the_acl = smb_xstrdup(poptGetOptArg(pc)); mode = SMB_ACL_SET; diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index a55dd4dd00..32506c4101 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -247,14 +247,12 @@ static BOOL print_tree(struct user_auth_info *user_info) { struct poptOption long_options[] = { POPT_AUTOHELP - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, { "broadcast", 'b', POPT_ARG_VAL, &use_bcast, True, "Use broadcast instead of using the master browser" }, { "domains", 'D', POPT_ARG_VAL, &level, LEV_WORKGROUP, "List only domains (workgroups) of tree" }, { "servers", 'S', POPT_ARG_VAL, &level, LEV_SERVER, "List domains(workgroups) and servers of tree" }, - { 0 } + POPT_COMMON_SAMBA + POPT_CREDENTIALS + POPT_TABLEEND }; poptContext pc; diff --git a/source3/utils/status.c b/source3/utils/status.c index 8014b133d9..7e87701752 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -559,10 +559,8 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo {"profile", 'P', POPT_ARG_NONE, &profile_only, 'P', "Do profiling" }, #endif /* WITH_PROFILE */ {"byterange", 'B', POPT_ARG_NONE, &show_brl, 'B', "Include byte range locks"}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - { 0, 0, 0, 0} + POPT_COMMON_SAMBA + POPT_TABLEEND }; setup_logging(argv[0],True); diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 22964214be..c0e4f7606e 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -186,7 +186,7 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ return ret; } -int main(int argc, const char *argv[]) + int main(int argc, const char *argv[]) { const char *config_file = dyn_CONFIGFILE; int s; @@ -206,7 +206,7 @@ int main(int argc, const char *argv[]) {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, {"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + POPT_COMMON_SAMBA {0,0,0,0} }; diff --git a/source3/web/swat.c b/source3/web/swat.c index 92dece6ecd..9a133e1330 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -1267,9 +1267,8 @@ static void printers_page(void) struct poptOption long_options[] = { POPT_AUTOHELP { "disable-authentication", 'a', POPT_ARG_VAL, &demo_mode, True, "Disable authentication (demo mode)" }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, - { 0, 0, 0, 0 } + POPT_COMMON_SAMBA + POPT_TABLEEND }; fault_setup(NULL); diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c index 5203d33745..be9d86952d 100644 --- a/source3/wrepld/server.c +++ b/source3/wrepld/server.c @@ -510,17 +510,13 @@ static void process(void) static BOOL log_stdout = False; struct poptOption long_options[] = { POPT_AUTOHELP - POPT_COMMON_SAMBA - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base }, { "daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon (default)" }, { "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools, etc)" }, { "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Run interactive (not a daemon)" }, { "port", 'p', POPT_ARG_INT, &wins_port, 'p', "Listen on the specified port" }, - { 0, 0, 0, 0 } + POPT_COMMON_SAMBA + POPT_TABLEEND }; int opt; poptContext pc; -- cgit From f9e66df9c75ae60a3402967a057c0022a0449747 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 11:31:01 +0000 Subject: Fix init function name and return value (This used to be commit 27f3fbac724847f2d0926d2231808871508a7dd9) --- source3/modules/developer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/modules/developer.c b/source3/modules/developer.c index a697abcd22..7ffc3ff50d 100644 --- a/source3/modules/developer.c +++ b/source3/modules/developer.c @@ -125,8 +125,8 @@ static size_t weird_push(void *cd, char **inbuf, size_t *inbytesleft, struct charset_functions weird_functions = {"WEIRD", weird_pull, weird_push}; -int init_module(void) +int charset_weird_init(void) { smb_register_charset(&weird_functions); - return 1; + return True; } -- cgit From 66876060fea57a317535fe869a95a0721d03acc0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 12:18:56 +0000 Subject: Define POPT_TABLEEND if current popt.h doesn't contain it already (This used to be commit de4bdf42d8f27b54260f58ff37d438c67623f446) --- source3/include/popt_common.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3') diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h index 7cdbc98862..380df4860e 100644 --- a/source3/include/popt_common.h +++ b/source3/include/popt_common.h @@ -25,6 +25,10 @@ extern struct poptOption popt_common_samba[]; extern struct poptOption popt_common_credentials[]; +#ifndef POPT_TABLEEND +#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL } +#endif + #define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_samba, 0, "Common samba options:", NULL }, #define POPT_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL }, -- cgit From 9ae249c6f10d3d548a6f1f19b34acf27e237f638 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 12:47:21 +0000 Subject: Add modules support to charset (This used to be commit cf3d31b9801d7ccb30334a92d4dc8a0ced2ecd31) --- source3/Makefile.in | 36 ++++++++++++---------- source3/configure.in | 3 ++ source3/lib/iconv.c | 84 ++++++++++++++++++++++++++++++++++------------------ 3 files changed, 78 insertions(+), 45 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 6cfa9be4d4..3c2a43dd0f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -54,6 +54,7 @@ LIBDIR = @libdir@ VFSLIBDIR = $(LIBDIR)/vfs PDBLIBDIR = $(LIBDIR)/pdb RPCLIBDIR = $(LIBDIR)/rpc +CHARSETLIBDIR = $(LIBDIR)/charset CONFIGDIR = @configdir@ VARDIR = @localstatedir@ MANDIR = @mandir@ @@ -138,7 +139,8 @@ VFS_MODULES = bin/vfs_audit.@SHLIBEXT@ bin/vfs_extd_audit.@SHLIBEXT@ bin/vfs_rec bin/vfs_netatalk.@SHLIBEXT@ bin/vfs_fake_perms.@SHLIBEXT@ PDB_MODULES = @PDB_MODULES@ RPC_MODULES = @RPC_MODULES@ -MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) +CHARSET_MODULES = @CHARSET_MODULES@ +MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(CHARSET_MODULES) ###################################################################### # object file lists @@ -166,7 +168,7 @@ LIB_OBJ = lib/charcnv.o lib/debug.o lib/fault.o \ lib/pam_errors.o intl/lang_tdb.o lib/account_pol.o \ lib/adt_tree.o lib/gencache.o $(TDB_OBJ) \ lib/module.o lib/genparser.o lib/genparser_samba.o \ - lib/ldap_escape.o + lib/ldap_escape.o @CHARSET_STATIC@ LIB_SMBD_OBJ = lib/system_smbd.o lib/util_smbd.o @@ -703,11 +705,11 @@ bin/smbd@EXEEXT@: $(SMBD_OBJ) @BUILD_POPT@ bin/.dummy bin/nmbd@EXEEXT@: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @BUILD_POPT@ bin/wrepld@EXEEXT@: $(WREPL_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(WREPL_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(WREPL_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @BUILD_POPT@ bin/swat@EXEEXT@: $(SWAT_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @@ -720,7 +722,7 @@ bin/rpcclient@EXEEXT@: $(RPCCLIENT_OBJ) @BUILD_POPT@ bin/.dummy bin/smbclient@EXEEXT@: $(CLIENT_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(LIBS) @BUILD_POPT@ bin/net@EXEEXT@: $(NET_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ @@ -752,23 +754,23 @@ bin/smbumount@EXEEXT@: $(UMOUNT_OBJ) bin/.dummy bin/testparm@EXEEXT@: $(TESTPARM_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(TESTPARM_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @BUILD_POPT@ bin/testprns@EXEEXT@: $(TESTPRNS_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(TESTPRNS_OBJ) $(LDFLAGS) $(PRINTLIBS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(TESTPRNS_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) $(LIBS) bin/smbstatus@EXEEXT@: $(STATUS_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(STATUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @BUILD_POPT@ bin/smbcontrol@EXEEXT@: $(SMBCONTROL_OBJ) bin/.dummy @echo Linking $@ - @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ $(SMBCONTROL_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ $(SMBCONTROL_OBJ) $(DYNEXP) $(LDFLAGS) $(LIBS) bin/smbtree@EXEEXT@: $(SMBTREE_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @BUILD_POPT@ bin/smbpasswd@EXEEXT@: $(SMBPASSWD_OBJ) bin/.dummy @echo Linking $@ @@ -780,19 +782,19 @@ bin/pdbedit@EXEEXT@: $(PDBEDIT_OBJ) @BUILD_POPT@ bin/.dummy bin/samtest@EXEEXT@: $(SAMTEST_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SAMTEST_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(SAMTEST_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS) $(DYNEXP) $(LIBS) @BUILD_POPT@ bin/smbgroupedit@EXEEXT@: $(SMBGROUPEDIT_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBGROUPEDIT_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBGROUPEDIT_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) bin/nmblookup@EXEEXT@: $(NMBLOOKUP_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ + @$(CC) $(FLAGS) -o $@ $(NMBLOOKUP_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) @BUILD_POPT@ bin/smbtorture@EXEEXT@: $(SMBTORTURE_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBTORTURE_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) bin/talloctort@EXEEXT@: $(TALLOCTORT_OBJ) bin/.dummy @echo Linking $@ @@ -844,7 +846,7 @@ bin/smbw_sample@EXEEXT@: $(SMBW_OBJ) utils/smbw_sample.o bin/.dummy bin/smbsh@EXEEXT@: $(SMBSH_OBJ) bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBSH_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBSH_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) bin/smbwrapper.@SHLIBEXT@: $(PICOBJS) bin/.dummy @echo Linking shared library $@ @@ -971,7 +973,7 @@ bin/nisplussam.@SHLIBEXT@: passdb/pdb_nisplus.o @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_nisplus.o \ @SONAMEFLAG@`basename $@` -bin/developer.@SHLIBEXT@: $(DEVEL_HELP_OBJ) +bin/weird.@SHLIBEXT@: $(DEVEL_HELP_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(DEVEL_HELP_OBJ) \ @SONAMEFLAG@`basename $@` @@ -1060,6 +1062,7 @@ installmodules: all installdirs @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(VFSLIBDIR) $(VFS_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(PDBLIBDIR) $(PDB_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(RPCLIBDIR) $(RPC_MODULES) + @$(SHEEL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(CHARSETLIBDIR) $(CHARSET_MODULES) installscripts: installdirs @$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS) @@ -1134,6 +1137,7 @@ uninstallmodules: @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(VFSLIBDIR) $(DESTDIR)$(VFS_MODULES) @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(PDBLIBDIR) $(DESTDIR)$(PDB_MODULES) @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(RPCLIBDIR) $(DESTDIR)$(RPC_MODULES) + @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(CHARSETLIBDIR) $(DESTDIR)$(CHARSET_MODULES) uninstallscripts: @$(SHELL) $(srcdir)/script/uninstallscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS) diff --git a/source3/configure.in b/source3/configure.in index 053577adf6..9ccbe08fa3 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3398,6 +3398,9 @@ SMB_MODULE($MODULE_rpc_spoolss, rpc_spoolss, \$(RPC_SPOOLSS_OBJ), bin/librpc_spo SMB_MODULE($MODULE_rpc_samr, rpc_samr, \$(RPC_SAMR_OBJ), bin/librpc_samr.so, RPC) SMB_SUBSYSTEM(RPC) +SMB_MODULE($MODULE_charset_weird, charset_weird, modules/developer.o, bin/developer.so, CHARSET) +SMB_SUBSYSTEM(CHARSET) + ################################################# # do extra things if we are running insure diff --git a/source3/lib/iconv.c b/source3/lib/iconv.c index 8b360a14c6..6a397f2d9e 100644 --- a/source3/lib/iconv.c +++ b/source3/lib/iconv.c @@ -2,7 +2,7 @@ Unix SMB/CIFS implementation. minimal iconv implementation Copyright (C) Andrew Tridgell 2001 - Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Jelmer Vernooij 2002,2003,2003,2003,2003 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 @@ -63,6 +63,17 @@ static struct charset_functions builtin_functions[] = { static struct charset_functions *charsets = NULL; +static struct charset_functions *find_charset_functions(const char *name) +{ + struct charset_functions *c = charsets; + while(c) { + if (strcasecmp(name, c->name) == 0)return c; + c = c->next; + } + + return NULL; +} + BOOL smb_register_charset(struct charset_functions *funcs) { struct charset_functions *c = charsets; @@ -93,6 +104,8 @@ void lazy_initialize_iconv(void) for(i = 0; builtin_functions[i].name; i++) smb_register_charset(&builtin_functions[i]); } + + static_init_charset; } /* if there was an error then reset the internal state, @@ -178,49 +191,70 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) ret->to_name = strdup(tocode); /* check for the simplest null conversion */ - if (strcmp(fromcode, tocode) == 0) { + if (strcasecmp(fromcode, tocode) == 0) { ret->direct = iconv_copy; return ret; } - while (from) { - if (strcasecmp(from->name, fromcode) == 0) break; - from = from->next; - } - - while (to) { - if (strcasecmp(to->name, tocode) == 0) break; - to = to->next; - } + /* check if we have a builtin function for this conversion */ + from = find_charset_functions(fromcode); + if(from)ret->pull = from->pull; + + to = find_charset_functions(tocode); + if(to)ret->push = to->push; + /* check if we can use iconv for this conversion */ #ifdef HAVE_NATIVE_ICONV - if (!from) { - ret->pull = sys_iconv; + if (!ret->pull) { ret->cd_pull = iconv_open("UCS-2LE", fromcode); - if (ret->cd_pull == (iconv_t)-1) goto failed; + if (ret->cd_pull != (iconv_t)-1) + ret->pull = sys_iconv; } - if (!to) { - ret->push = sys_iconv; + if (!ret->push) { ret->cd_push = iconv_open(tocode, "UCS-2LE"); - if (ret->cd_push == (iconv_t)-1) goto failed; - } -#else - if (!from || !to) { - goto failed; + if (ret->cd_push != (iconv_t)-1) + ret->push = sys_iconv; } #endif + + /* check if there is a module available that can do this conversion */ + if (!ret->pull && smb_probe_module("charset", fromcode)) { + if(!(from = find_charset_functions(fromcode))) + DEBUG(0, ("Module %s doesn't provide charset %s!\n", fromcode, fromcode)); + else + ret->pull = from->pull; + } + + if (!ret->push && smb_probe_module("charset", tocode)) { + if(!(to = find_charset_functions(tocode))) + DEBUG(0, ("Module %s doesn't provide charset %s!\n", tocode, tocode)); + else + ret->push = to->push; + } + + if (!ret->push || !ret->pull) { + SAFE_FREE(ret->from_name); + SAFE_FREE(ret->to_name); + SAFE_FREE(ret); + errno = EINVAL; + return (smb_iconv_t)-1; + } /* check for conversion to/from ucs2 */ if (strcasecmp(fromcode, "UCS-2LE") == 0 && to) { ret->direct = to->push; + ret->push = ret->pull = NULL; return ret; } + if (strcasecmp(tocode, "UCS-2LE") == 0 && from) { ret->direct = from->pull; + ret->push = ret->pull = NULL; return ret; } + /* Check if we can do the conversion direct */ #ifdef HAVE_NATIVE_ICONV if (strcasecmp(fromcode, "UCS-2LE") == 0) { ret->direct = sys_iconv; @@ -236,15 +270,7 @@ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode) } #endif - /* the general case has to go via a buffer */ - if (!ret->pull) ret->pull = from->pull; - if (!ret->push) ret->push = to->push; return ret; - -failed: - SAFE_FREE(ret); - errno = EINVAL; - return (smb_iconv_t)-1; } /* -- cgit From 41a09c3c533ab170097309e1f91314eda32e4f4c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 14:15:14 +0000 Subject: Revoke some of the popt patch from metze I applied earlier today. It added some double options and broke some parameters. (This used to be commit d5f9b0275c91512e1926504f22aaeec2d104430d) --- source3/client/client.c | 3 ++- source3/include/popt_common.h | 6 +++++- source3/lib/popt_common.c | 25 ++++++++++++++++++------- source3/nmbd/nmbd.c | 1 + source3/nsswitch/wbinfo.c | 2 +- source3/nsswitch/winbindd.c | 1 + source3/rpcclient/rpcclient.c | 3 ++- source3/smbd/server.c | 1 + source3/utils/net.c | 1 + source3/utils/nmblookup.c | 1 + source3/utils/ntlm_auth.c | 3 ++- source3/utils/pdbedit.c | 2 +- source3/utils/smbcacls.c | 2 +- source3/utils/smbtree.c | 2 +- source3/utils/testparm.c | 4 ++-- source3/wrepld/server.c | 1 + 16 files changed, 41 insertions(+), 17 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index 8d6730cdc6..da4f025755 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2603,7 +2603,8 @@ static void remember_query_host(const char *arg, { "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" }, { "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" }, POPT_COMMON_SAMBA - POPT_CREDENTIALS + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS POPT_TABLEEND }; diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h index 380df4860e..57850bf682 100644 --- a/source3/include/popt_common.h +++ b/source3/include/popt_common.h @@ -23,6 +23,8 @@ /* Common popt structures */ extern struct poptOption popt_common_samba[]; +extern struct poptOption popt_common_connection[]; +extern struct poptOption popt_common_version[]; extern struct poptOption popt_common_credentials[]; #ifndef POPT_TABLEEND @@ -30,7 +32,9 @@ extern struct poptOption popt_common_credentials[]; #endif #define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_samba, 0, "Common samba options:", NULL }, -#define POPT_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL }, +#define POPT_COMMON_CONNECTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_connection, 0, "Connection options:", NULL }, +#define POPT_COMMON_VERSION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version, 0, "Common samba options:", NULL }, +#define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL }, struct user_auth_info { pstring username; diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 06ba4fc898..edd54c13d5 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -112,22 +112,33 @@ static void popt_common_callback(poptContext con, } } -struct poptOption popt_common_samba[] = { +struct poptOption popt_common_connection[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, - { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", - "CONFIGFILE" }, { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", "SOCKETOPTIONS" }, - { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, - { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", - "LOGFILEBASE" }, { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, POPT_TABLEEND }; +struct poptOption popt_common_samba[] = { + { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, + { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, + { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, + { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, + POPT_TABLEEND +}; + +struct poptOption popt_common_version[] = { + { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, + POPT_TABLEEND +}; + + + /**************************************************************************** * get a password from a a file or file descriptor * exit on failure diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index d013b79d3e..184a86e2cf 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -601,6 +601,7 @@ static BOOL open_sockets(BOOL isdaemon, int port) {"hosts", 'H', POPT_ARG_STRING, dyn_LMHOSTSFILE, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION { NULL } }; pstring logfile; diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index fe11cd6528..5ec8e534aa 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -711,7 +711,7 @@ int main(int argc, char **argv) { "set-auth-user", 'A', POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", "user%password" }, { "get-auth-user", 0, POPT_ARG_NONE, NULL, OPT_GET_AUTH_USER, "Retrieve user and password used by winbindd (root only)", NULL }, { "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if it is alive" }, - POPT_COMMON_SAMBA + POPT_COMMON_VERSION POPT_TABLEEND }; diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index cd72a4f572..0f34924e9d 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -820,6 +820,7 @@ int main(int argc, char **argv) { "dual-daemon", 'B', POPT_ARG_VAL, &opt_dual_daemon, True, "Dual daemon mode" }, { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, False, "Disable caching" }, POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION POPT_TABLEEND }; poptContext pc; diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 97a944dbf9..6c1d05b3e9 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -507,7 +507,8 @@ out_free: {"command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated cmds", "COMMANDS"}, {"dest-ip", 'I', POPT_ARG_STRING, &opt_ipaddr, 'I', "Specify destination IP address", "IP"}, POPT_COMMON_SAMBA - POPT_CREDENTIALS + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS POPT_TABLEEND }; diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 715e916263..a166027acb 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -670,6 +670,7 @@ static BOOL init_structs(void ) {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION { NULL } }; diff --git a/source3/utils/net.c b/source3/utils/net.c index d6945ceefb..3ab34e7aa9 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -530,6 +530,7 @@ static struct functable net_func[] = { {"force", 'f', POPT_ARG_NONE, &opt_force}, {"timeout", 't', POPT_ARG_INT, &opt_timeout}, {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass}, + {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup}, POPT_COMMON_SAMBA { 0, 0, 0, 0} }; diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 88038fb566..85f092c8b0 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -203,6 +203,7 @@ int main(int argc,char *argv[]) { "root-port", 'r', POPT_ARG_VAL, &RootPort, True, "Use root port 137 (Win95 only replies to this)" }, { "lookup-by-ip", 'A', POPT_ARG_VAL, &lookup_by_ip, True, "Do a node status on as an IP Address" }, POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION { 0, 0, 0, 0 } }; diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c index a28bbf9364..f02bd5f5b3 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -457,7 +457,8 @@ enum { { "request-lm-key", 0, POPT_ARG_NONE, &request_lm_key, OPT_LM_KEY, "Retreive LM session key"}, { "request-nt-key", 0, POPT_ARG_NONE, &request_nt_key, OPT_NT_KEY, "Retreive NT session key"}, POPT_COMMON_SAMBA - POPT_CREDENTIALS + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS POPT_TABLEEND }; diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 03be2571e5..f33dbd9f1c 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -516,7 +516,7 @@ int main (int argc, char **argv) poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP - {"list", 'l', POPT_ARG_NONE, &list_users, 0, "list all users", NULL}, + {"list", 'L', POPT_ARG_NONE, &list_users, 0, "list all users", NULL}, {"verbose", 'v', POPT_ARG_NONE, &verbose, 0, "be verbose", NULL }, {"smbpasswd-style", 'w',POPT_ARG_NONE, &spstyle, 0, "give output in smbpasswd style", NULL}, {"user", 'u', POPT_ARG_STRING, &user_name, 0, "use username", "USER" }, diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index ac15cf1aa0..562fd9943f 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -758,7 +758,7 @@ static struct cli_state *connect_one(const char *share) { "numeric", 0, POPT_ARG_NONE, &numeric, True, "Don't resolve sids or masks to names" }, { "test-args", 't', POPT_ARG_NONE, &test_args, True, "Test arguments"}, POPT_COMMON_SAMBA - POPT_CREDENTIALS + POPT_COMMON_CREDENTIALS { NULL } }; diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 32506c4101..52de5ab467 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -251,7 +251,7 @@ static BOOL print_tree(struct user_auth_info *user_info) { "domains", 'D', POPT_ARG_VAL, &level, LEV_WORKGROUP, "List only domains (workgroups) of tree" }, { "servers", 'S', POPT_ARG_VAL, &level, LEV_SERVER, "List domains(workgroups) and servers of tree" }, POPT_COMMON_SAMBA - POPT_CREDENTIALS + POPT_COMMON_CREDENTIALS POPT_TABLEEND }; poptContext pc; diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index c0e4f7606e..4c8a2ccf63 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -206,8 +206,8 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ {"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"}, {"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"}, {"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"}, - POPT_COMMON_SAMBA - {0,0,0,0} + POPT_COMMON_VERSION + POPT_TABLEEND }; pc = poptGetContext(NULL, argc, argv, long_options, diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c index be9d86952d..196ea0d1d1 100644 --- a/source3/wrepld/server.c +++ b/source3/wrepld/server.c @@ -516,6 +516,7 @@ static void process(void) { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Run interactive (not a daemon)" }, { "port", 'p', POPT_ARG_INT, &wins_port, 'p', "Listen on the specified port" }, POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION POPT_TABLEEND }; int opt; -- cgit From 66c321232a7ce39157fe91e6b5a0d21d9b5e25bf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 14:32:11 +0000 Subject: Don't use old usage() function, but the one from popt. Remove some useless arguments (This used to be commit 8df30059ef100a4d5e21501d7746427b4d312589) --- source3/nmbd/nmbd.c | 1 - source3/nsswitch/winbindd.c | 1 - source3/smbd/server.c | 1 - source3/wrepld/server.c | 14 ++------------ 4 files changed, 2 insertions(+), 15 deletions(-) (limited to 'source3') diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 184a86e2cf..d013b79d3e 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -601,7 +601,6 @@ static BOOL open_sockets(BOOL isdaemon, int port) {"hosts", 'H', POPT_ARG_STRING, dyn_LMHOSTSFILE, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, POPT_COMMON_SAMBA - POPT_COMMON_CONNECTION { NULL } }; pstring logfile; diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 0f34924e9d..cd72a4f572 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -820,7 +820,6 @@ int main(int argc, char **argv) { "dual-daemon", 'B', POPT_ARG_VAL, &opt_dual_daemon, True, "Dual daemon mode" }, { "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, False, "Disable caching" }, POPT_COMMON_SAMBA - POPT_COMMON_CONNECTION POPT_TABLEEND }; poptContext pc; diff --git a/source3/smbd/server.c b/source3/smbd/server.c index a166027acb..715e916263 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -670,7 +670,6 @@ static BOOL init_structs(void ) {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, POPT_COMMON_SAMBA - POPT_COMMON_CONNECTION { NULL } }; diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c index 196ea0d1d1..504818b8d5 100644 --- a/source3/wrepld/server.c +++ b/source3/wrepld/server.c @@ -159,15 +159,6 @@ void exit_server(const char *reason) exit(0); } -/**************************************************************************** - Usage of the program. -****************************************************************************/ - -static void usage(char *pname) -{ - -} - /**************************************************************************** Create an fd_set containing all the sockets in the subnet structures, plus the broadcast sockets. @@ -516,7 +507,6 @@ static void process(void) { "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Run interactive (not a daemon)" }, { "port", 'p', POPT_ARG_INT, &wins_port, 'p', "Listen on the specified port" }, POPT_COMMON_SAMBA - POPT_COMMON_CONNECTION POPT_TABLEEND }; int opt; @@ -539,11 +529,10 @@ static void process(void) } } - poptFreeContext(pc); if (log_stdout && Fork) { d_printf("Can't log to stdout (-S) unless daemon is in foreground (-F) or interactive (-i)\n"); - usage(argv[0]); + poptPrintUsage(pc, stderr, 0); exit(1); } @@ -671,6 +660,7 @@ static void process(void) process(); + poptFreeContext(pc); exit_server("normal exit"); return(0); } -- cgit From a4d819e1e8a749f92c4e3fd39e8f025809e9d5c0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 16:15:10 +0000 Subject: Add mapping for Bad Network Path (This used to be commit 1481cd9ecf1658312424c193d8cd3632766eb058) --- source3/libsmb/clierror.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3') diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c index b66a6bcba8..cea736ef18 100644 --- a/source3/libsmb/clierror.c +++ b/source3/libsmb/clierror.c @@ -231,6 +231,7 @@ static struct { {NT_STATUS_UNSUCCESSFUL, EINVAL}, {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, {NT_STATUS_IN_PAGE_ERROR, EFAULT}, + {NT_STATUS_BAD_NETWORK_NAME, ENOENT}, #ifdef EDQUOT {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, -- cgit From 75b3445d04fc5c24f39fb18157ac79b1b82c6ce6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 16:16:13 +0000 Subject: Add static to satisfy exotic compilers (This used to be commit 269c93ca269e5badd5475d9ad53d06f9cb111d2c) --- source3/client/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index da4f025755..b6c4b704a9 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2583,7 +2583,7 @@ static void remember_query_host(const char *arg, BOOL message = False; extern char tar_type; pstring term_code; - const char *new_name_resolve_order = NULL; + static const char *new_name_resolve_order = NULL; poptContext pc; char *p; int rc = 0; -- cgit From acffe03f936268357b61c48631a8842c4c2e623e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 18:25:31 +0000 Subject: Simplify modules interface and make it easier to build complete subsystems as modules (--with-shared-modules=rpc,pdb_xml,pdb_ldap works now, for example) (This used to be commit f622bdc691fabed218598fb0546b9e933aed63ed) --- source3/aclocal.m4 | 26 +++++++++++++++-------- source3/configure.in | 58 ++++++++++++++++++++-------------------------------- 2 files changed, 39 insertions(+), 45 deletions(-) (limited to 'source3') diff --git a/source3/aclocal.m4 b/source3/aclocal.m4 index 15508206c3..4814a86a96 100644 --- a/source3/aclocal.m4 +++ b/source3/aclocal.m4 @@ -37,18 +37,26 @@ fi ]) dnl Mark specified module as shared -dnl SMB_MODULE(type,name,static_files,shared_files,subsystem) +dnl SMB_MODULE(name,static_files,shared_files,subsystem) AC_DEFUN(SMB_MODULE, [ - AC_MSG_CHECKING([how to build $2]) - if test x"$1" = xSHARED; then - AC_DEFINE([$2][_init], [init_module], [Whether to build $2 as shared module]) - $5_MODULES="$$5_MODULES $4" + AC_MSG_CHECKING([how to build $1]) + if test "$[MODULE_][$1]"; then + DEST=$[MODULE_][$1] + elif test "$[MODULE_]translit([$4], [A-Z], [a-z])"; then + DEST=$[MODULE_]translit([$4], [A-Z], [a-z]) + else + DEST=$[MODULE_DEFAULT_][$1] + fi + + if test x"$DEST" = xSHARED; then + AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module]) + $5_MODULES="$$4_MODULES $3" AC_MSG_RESULT([shared]) - elif test x"$1" = xSTATIC; then - [init_static_modules_]translit([$5], [A-Z], [a-z])="$[init_static_modules_]translit([$5], [A-Z], [a-z]) $2_init();" - $5_STATIC="$$5_STATIC $3" - AC_SUBST($5_STATIC) + elif test x"$DEST" = xSTATIC; then + [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z]) $1_init();" + $5_STATIC="$$4_STATIC $2" + AC_SUBST($4_STATIC) AC_MSG_RESULT([static]) else AC_MSG_RESULT([not]) diff --git a/source3/configure.in b/source3/configure.in index 9ccbe08fa3..cbd1eec710 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -239,7 +239,7 @@ AC_VALIDATE_CACHE_SYSTEM_TYPE DYNEXP= dnl Add modules that have to be built by default here -default_modules="pdb_smbpasswd pdb_tdb pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_netlog rpc_dfs rpc_srv rpc_spoolss" +default_modules="pdb_smbpasswd pdb_tdbsam pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss" # # Config CPPFLAG settings for strange OS's that must be set @@ -2449,23 +2449,6 @@ AC_ARG_WITH(tdbsam, AC_MSG_RESULT(no) ) -################################################# -# check for a NISPLUS password database -AC_MSG_CHECKING(whether to use NISPLUS SAM database) -AC_ARG_WITH(nisplussam, -[ --with-nisplussam Include NISPLUS SAM support (default=no)], -[ case "$withval" in - yes) - AC_MSG_RESULT(yes) - AC_DEFINE(WITH_NISPLUS_SAM,1,[Whether to include nisplus SAM support]) - ;; - *) - AC_MSG_RESULT(no) - ;; - esac ], - AC_MSG_RESULT(no) -) - ######################################################################################## ## ## END OF TESTS FOR SAM BACKENDS. @@ -3357,7 +3340,7 @@ AC_SUBST(PYTHON) for i in `echo $default_modules | sed -e's/,/ /g'` do dnl Set to shared instead of static when dlopen() is available? - eval MODULE_$i=STATIC + eval MODULE_DEFAULT_$i=STATIC done AC_ARG_WITH(static-modules, @@ -3378,27 +3361,30 @@ AC_ARG_WITH(shared-modules, done fi ]) -SMB_MODULE($MODULE_pdb_xml, pdb_xml, modules/xml.o, bin/xml.so PDB) -SMB_MODULE($MODULE_pdb_mysql, pdb_mysql, modules/mysql.o, bin/mysql.so, PDB) -SMB_MODULE($MODULE_pdb_ldap, pdb_ldap, passdb/pdb_ldap.o, bin/ldapsam.so, PDB) -SMB_MODULE($MODULE_pdb_smbpasswd, pdb_smbpasswd, passdb/pdb_smbpasswd.o, bin/smbpasswd.so, PDB) -SMB_MODULE($MODULE_pdb_tdb, pdb_tdbsam, passdb/pdb_tdb.o, bin/tdbsam.so, PDB) -SMB_MODULE($MODULE_pdb_nisplus, pdb_nisplussam, passdb/pdb_nisplus.o, bin/nisplussam.so, PDB) -SMB_MODULE($MODULE_pdb_unix, pdb_unix, passdb/pdb_unix.o, bin/unixsam.so, PDB) -SMB_MODULE(STATIC, pdb_guest, passdb/pdb_guest.o, bin/guest.so, PDB) +# Always built these modules static +MODULE_pdb_guest=STATIC + +SMB_MODULE(pdb_xml, modules/xml.o, bin/xml.so, PDB) +SMB_MODULE(pdb_mysql, modules/mysql.o, bin/mysql.so, PDB) +SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o, bin/ldapsam.so, PDB) +SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, bin/smbpasswd.so, PDB) +SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, bin/tdbsam.so, PDB) +SMB_MODULE(pdb_nisplussam, passdb/pdb_nisplus.o, bin/nisplussam.so, PDB) +SMB_MODULE(pdb_unix, passdb/pdb_unix.o, bin/unixsam.so, PDB) +SMB_MODULE(pdb_guest, passdb/pdb_guest.o, bin/guest.so, PDB) SMB_SUBSYSTEM(PDB) -SMB_MODULE($MODULE_rpc_lsa, rpc_lsa, \$(RPC_LSA_OBJ), bin/librpc_lsa.so, RPC) -SMB_MODULE($MODULE_rpc_reg, rpc_reg, \$(RPC_REG_OBJ), bin/librpc_reg.so, RPC) -SMB_MODULE($MODULE_rpc_wks, rpc_wks, \$(RPC_WKS_OBJ), bin/librpc_wks.so, RPC) -SMB_MODULE($MODULE_rpc_netlog, rpc_net, \$(RPC_NETLOG_OBJ), bin/librpc_netlog.so, RPC) -SMB_MODULE($MODULE_rpc_dfs, rpc_dfs, \$(RPC_DFS_OBJ), bin/librpc_dfs.so, RPC) -SMB_MODULE($MODULE_rpc_srv, rpc_srv, \$(RPC_SVC_OBJ), bin/librpc_srvsvc.so, RPC) -SMB_MODULE($MODULE_rpc_spoolss, rpc_spoolss, \$(RPC_SPOOLSS_OBJ), bin/librpc_spoolss.so, RPC) -SMB_MODULE($MODULE_rpc_samr, rpc_samr, \$(RPC_SAMR_OBJ), bin/librpc_samr.so, RPC) +SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), bin/librpc_lsarpc.so, RPC) +SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), bin/librpc_reg.so, RPC) +SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), bin/librpc_wks.so, RPC) +SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), bin/librpc_netlog.so, RPC) +SMB_MODULE(rpc_dfs, \$(RPC_DFS_OBJ), bin/librpc_dfs.so, RPC) +SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), bin/librpc_srvsvc.so, RPC) +SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), bin/librpc_spoolss.so, RPC) +SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), bin/librpc_samr.so, RPC) SMB_SUBSYSTEM(RPC) -SMB_MODULE($MODULE_charset_weird, charset_weird, modules/developer.o, bin/developer.so, CHARSET) +SMB_MODULE(charset_weird, modules/developer.o, bin/developer.so, CHARSET) SMB_SUBSYSTEM(CHARSET) ################################################# -- cgit From f2c1d6895fc50526b9be9a703a76d15dd79d3185 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 18:38:59 +0000 Subject: Give error message when module doesn't seem to contain pipe functions (This used to be commit 4dd16790436d18f5ac5868538309128e3f8ad1cc) --- source3/rpc_server/srv_pipe.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source3') diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index d6b774c566..2ab554f122 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -810,6 +810,11 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) break; } } + + if (i == rpc_lookup_size) { + DEBUG(0, ("module %s doesn't provide functions for pipe %s!\m", p->name, p->name)); + return False; + } } /* decode the bind request */ -- cgit From 9ba1ed52719df0a5eef723ecbfec11f6035a9710 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 19:18:24 +0000 Subject: When using --with-static-modules=subsystem, don't build modules that can't be build (This used to be commit bb943a68af20f87a4b2d6b257585615d1792dd33) --- source3/aclocal.m4 | 2 +- source3/configure.in | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/aclocal.m4 b/source3/aclocal.m4 index 4814a86a96..79fbc8628e 100644 --- a/source3/aclocal.m4 +++ b/source3/aclocal.m4 @@ -43,7 +43,7 @@ AC_DEFUN(SMB_MODULE, AC_MSG_CHECKING([how to build $1]) if test "$[MODULE_][$1]"; then DEST=$[MODULE_][$1] - elif test "$[MODULE_]translit([$4], [A-Z], [a-z])"; then + elif test "$[MODULE_]translit([$4], [A-Z], [a-z])" -a "$[MODULE_DEFAULT_][$1]"; then DEST=$[MODULE_]translit([$4], [A-Z], [a-z]) else DEST=$[MODULE_DEFAULT_][$1] diff --git a/source3/configure.in b/source3/configure.in index cbd1eec710..15ff11eaa8 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3343,6 +3343,11 @@ do eval MODULE_DEFAULT_$i=STATIC done +# Always built these modules static +MODULE_pdb_guest=STATIC +MODULE_rpc_spools=STATIC +MODULE_rpc_srv=STATIC + AC_ARG_WITH(static-modules, [ --with-static-modules=MODULES Comma-seperated list of names of modules to statically link in], [ if test $withval; then @@ -3361,9 +3366,6 @@ AC_ARG_WITH(shared-modules, done fi ]) -# Always built these modules static -MODULE_pdb_guest=STATIC - SMB_MODULE(pdb_xml, modules/xml.o, bin/xml.so, PDB) SMB_MODULE(pdb_mysql, modules/mysql.o, bin/mysql.so, PDB) SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o, bin/ldapsam.so, PDB) -- cgit From cdfe4b9b85441678067c37e438ed1c29ee5fa1cf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 19:53:02 +0000 Subject: Fix two typos (This used to be commit 898a246c1650326cbd9b8ca49fb93963e589ea1f) --- source3/configure.in | 2 +- source3/rpc_server/srv_pipe.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 15ff11eaa8..0c8301d1da 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3345,7 +3345,7 @@ done # Always built these modules static MODULE_pdb_guest=STATIC -MODULE_rpc_spools=STATIC +MODULE_rpc_spoolss=STATIC MODULE_rpc_srv=STATIC AC_ARG_WITH(static-modules, diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index 2ab554f122..5d8b7d39e9 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -812,7 +812,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p) } if (i == rpc_lookup_size) { - DEBUG(0, ("module %s doesn't provide functions for pipe %s!\m", p->name, p->name)); + DEBUG(0, ("module %s doesn't provide functions for pipe %s!\n", p->name, p->name)); return False; } } -- cgit From 6d6f1c0522201792412b4618098536bcc45f4919 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Mar 2003 23:03:46 +0000 Subject: - Add support to auth/ for the new modules system - Quite some small fixes (also fixes the build) (This used to be commit 3defbd5e0633acfa4631531b49601c7706072d86) --- source3/Makefile.in | 8 +++- source3/aclocal.m4 | 4 +- source3/auth/auth.c | 94 ++++++++++++++++++++++++++++----------------- source3/auth/auth_builtin.c | 54 ++++---------------------- source3/auth/auth_domain.c | 7 ++++ source3/auth/auth_rhosts.c | 7 ++++ source3/auth/auth_sam.c | 8 ++++ source3/auth/auth_server.c | 5 +++ source3/auth/auth_unix.c | 4 ++ source3/auth/auth_winbind.c | 5 +++ source3/configure.in | 19 ++++++--- source3/include/auth.h | 4 ++ 12 files changed, 129 insertions(+), 90 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 3c2a43dd0f..daf495c25e 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -55,6 +55,7 @@ VFSLIBDIR = $(LIBDIR)/vfs PDBLIBDIR = $(LIBDIR)/pdb RPCLIBDIR = $(LIBDIR)/rpc CHARSETLIBDIR = $(LIBDIR)/charset +AUTHLIBDIR = $(LIBDIR)/auth CONFIGDIR = @configdir@ VARDIR = @localstatedir@ MANDIR = @mandir@ @@ -140,7 +141,8 @@ VFS_MODULES = bin/vfs_audit.@SHLIBEXT@ bin/vfs_extd_audit.@SHLIBEXT@ bin/vfs_rec PDB_MODULES = @PDB_MODULES@ RPC_MODULES = @RPC_MODULES@ CHARSET_MODULES = @CHARSET_MODULES@ -MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(CHARSET_MODULES) +AUTH_MODULES = @AUTH_MODULES@ +MODULES = $(VFS_MODULES) $(PDB_MODULES) $(RPC_MODULES) $(CHARSET_MODULES) $(AUTH_MODULES) ###################################################################### # object file lists @@ -1058,11 +1060,12 @@ installbin: all installdirs @$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(VARDIR) $(BIN_PROGS) -installmodules: all installdirs +installmodules: all modules installdirs @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(VFSLIBDIR) $(VFS_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(PDBLIBDIR) $(PDB_MODULES) @$(SHELL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(RPCLIBDIR) $(RPC_MODULES) @$(SHEEL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(CHARSETLIBDIR) $(CHARSET_MODULES) + @$(SHEEL) $(srcdir)/script/installmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(AUTHLIBDIR) $(AUTH_MODULES) installscripts: installdirs @$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS) @@ -1138,6 +1141,7 @@ uninstallmodules: @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(PDBLIBDIR) $(DESTDIR)$(PDB_MODULES) @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(RPCLIBDIR) $(DESTDIR)$(RPC_MODULES) @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(CHARSETLIBDIR) $(DESTDIR)$(CHARSET_MODULES) + @$(SHELL) $(srcdir)/script/uninstallmodules.sh $(INSTALLPERMS) $(DESTDIR)$(BASEDIR) $(DESTDIR)$(AUTHLIBDIR) $(DESTDIR)$(AUTH_MODULES) uninstallscripts: @$(SHELL) $(srcdir)/script/uninstallscripts.sh $(INSTALLPERMS) $(DESTDIR)$(BINDIR) $(SCRIPTS) diff --git a/source3/aclocal.m4 b/source3/aclocal.m4 index 79fbc8628e..5d9070fcd9 100644 --- a/source3/aclocal.m4 +++ b/source3/aclocal.m4 @@ -51,11 +51,11 @@ AC_DEFUN(SMB_MODULE, if test x"$DEST" = xSHARED; then AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module]) - $5_MODULES="$$4_MODULES $3" + $4_MODULES="$$4_MODULES $3" AC_MSG_RESULT([shared]) elif test x"$DEST" = xSTATIC; then [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z]) $1_init();" - $5_STATIC="$$4_STATIC $2" + $4_STATIC="$$4_STATIC $2" AC_SUBST($4_STATIC) AC_MSG_RESULT([static]) else diff --git a/source3/auth/auth.c b/source3/auth/auth.c index 8b33010e91..4416f93fba 100644 --- a/source3/auth/auth.c +++ b/source3/auth/auth.c @@ -23,27 +23,45 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH -/** List of various built-in authentication modules */ - -static const struct auth_init_function_entry builtin_auth_init_functions[] = { - { "guest", auth_init_guest }, - { "rhosts", auth_init_rhosts }, - { "hostsequiv", auth_init_hostsequiv }, - { "sam", auth_init_sam }, - { "samstrict", auth_init_samstrict }, - { "samstrict_dc", auth_init_samstrict_dc }, - { "unix", auth_init_unix }, - { "smbserver", auth_init_smbserver }, - { "ntdomain", auth_init_ntdomain }, - { "trustdomain", auth_init_trustdomain }, - { "winbind", auth_init_winbind }, -#ifdef DEVELOPER - { "name_to_ntstatus", auth_init_name_to_ntstatus }, - { "fixed_challenge", auth_init_fixed_challenge }, -#endif - { "plugin", auth_init_plugin }, - { NULL, NULL} -}; +static struct auth_init_function_entry *backends = NULL; + +BOOL smb_register_auth(const char *name, auth_init_function init, int version) +{ + struct auth_init_function_entry *entry = backends; + + if(version != AUTH_INTERFACE_VERSION) + return False; + + DEBUG(5,("Attempting to register auth backend %s\n", name)); + + while(entry) { + if (strequal(name, entry->name)) { + DEBUG(0,("There already is an auth backend registered with the name %s!\n", name)); + return False; + } + entry = entry->next; + } + + entry = smb_xmalloc(sizeof(struct auth_init_function_entry)); + entry->name = smb_xstrdup(name); + entry->init = init; + + DLIST_ADD(backends, entry); + DEBUG(5,("Successfully added auth backend '%s'\n", name)); + return True; +} + +static struct auth_init_function_entry *auth_find_backend_entry(const char *name) +{ + struct auth_init_function_entry *entry = backends; + + while(entry) { + if (strequal(entry->name, name)) return entry; + entry = entry->next; + } + + return NULL; +} /**************************************************************************** Try to get a challenge out of the various authentication modules. @@ -325,8 +343,8 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, auth_methods *list = NULL; auth_methods *t = NULL; auth_methods *tmp; - int i; NTSTATUS nt_status; + static BOOL initialised_static_modules = False; if (!text_list) { DEBUG(2,("make_auth_context_text_list: No auth method list!?\n")); @@ -335,11 +353,17 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, if (!NT_STATUS_IS_OK(nt_status = make_auth_context(auth_context))) return nt_status; + + /* Initialise static modules if not done so yet */ + if(!initialised_static_modules) { + static_init_auth; + initialised_static_modules = True; + } for (;*text_list; text_list++) { DEBUG(5,("make_auth_context_text_list: Attempting to find an auth method to match %s\n", *text_list)); - for (i = 0; builtin_auth_init_functions[i].name; i++) { + struct auth_init_function_entry *entry; char *module_name = smb_xstrdup(*text_list); char *module_params = NULL; char *p; @@ -353,20 +377,20 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, trim_string(module_name, " ", " "); - if (strequal(builtin_auth_init_functions[i].name, module_name)) { - DEBUG(5,("make_auth_context_text_list: Found auth method %s (at pos %d)\n", *text_list, i)); - if (NT_STATUS_IS_OK(builtin_auth_init_functions[i].init(*auth_context, module_params, &t))) { - DEBUG(5,("make_auth_context_text_list: auth method %s has a valid init\n", - *text_list)); - DLIST_ADD_END(list, t, tmp); - } else { - DEBUG(0,("make_auth_context_text_list: auth method %s did not correctly init\n", - *text_list)); - } - break; + entry = auth_find_backend_entry(module_name); + + if(!(entry = auth_find_backend_entry(module_name)) && !smb_probe_module("auth", module_name) && + !(entry = auth_find_backend_entry(module_name))) { + DEBUG(0,("make_auth_context_text_list: can't find auth method %s!\n", module_name)); + } else if (!NT_STATUS_IS_OK(entry->init(*auth_context, module_params, &t))) { + DEBUG(0,("make_auth_context_text_list: auth method %s did not correctly init\n", + *text_list)); + } else { + DEBUG(5,("make_auth_context_text_list: auth method %s has a valid init\n", + *text_list)); + DLIST_ADD_END(list, t, tmp); } SAFE_FREE(module_name); - } } (*auth_context)->auth_method_list = list; diff --git a/source3/auth/auth_builtin.c b/source3/auth/auth_builtin.c index 3b0b84b525..509a4afba9 100644 --- a/source3/auth/auth_builtin.c +++ b/source3/auth/auth_builtin.c @@ -1,6 +1,6 @@ /* Unix SMB/CIFS implementation. - Generic authenticaion types + Generic authentication types Copyright (C) Andrew Bartlett 2001-2002 Copyright (C) Jelmer Vernooij 2002 @@ -161,50 +161,12 @@ NTSTATUS auth_init_fixed_challenge(struct auth_context *auth_context, const char return NT_STATUS_OK; } -/** - * Outsorce an auth module to an external loadable .so - * - * Only works on systems with dlopen() etc. - **/ - -/* Plugin modules initialisation */ - -NTSTATUS auth_init_plugin(struct auth_context *auth_context, const char *param, auth_methods **auth_method) +int auth_builtin_init(void) { - void * dl_handle; - char *plugin_param, *plugin_name, *p; - auth_init_function plugin_init; - - if (param == NULL) { - DEBUG(0, ("auth_init_plugin: The plugin module needs an argument!\n")); - return NT_STATUS_UNSUCCESSFUL; - } - - plugin_name = smb_xstrdup(param); - p = strchr(plugin_name, ':'); - if (p) { - *p = 0; - plugin_param = p+1; - trim_string(plugin_param, " ", " "); - } else plugin_param = NULL; - - trim_string(plugin_name, " ", " "); - - DEBUG(5, ("auth_init_plugin: Trying to load auth plugin %s\n", plugin_name)); - dl_handle = sys_dlopen(plugin_name, RTLD_NOW ); - if (!dl_handle) { - DEBUG(0, ("auth_init_plugin: Failed to load auth plugin %s using sys_dlopen (%s)\n", - plugin_name, sys_dlerror())); - return NT_STATUS_UNSUCCESSFUL; - } - - plugin_init = sys_dlsym(dl_handle, "auth_init"); - if (!plugin_init){ - DEBUG(0, ("Failed to find function 'auth_init' using sys_dlsym in sam plugin %s (%s)\n", - plugin_name, sys_dlerror())); - return NT_STATUS_UNSUCCESSFUL; - } - - DEBUG(5, ("Starting sam plugin %s with paramater %s\n", plugin_name, plugin_param?plugin_param:"(null)")); - return plugin_init(auth_context, plugin_param, auth_method); + smb_register_auth("guest", auth_init_guest, AUTH_INTERFACE_VERSION); +#ifdef DEVELOPER + smb_register_auth("fixed_challenge", auth_init_fixed_challenge, AUTH_INTERFACE_VERSION); + smb_register_auth("name_to_ntstatus", auth_init_name_to_ntstatus, AUTH_INTERFACE_VERSION); +#endif + return True; } diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index 7cf7ed1199..9ca2f4e190 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -545,3 +545,10 @@ NTSTATUS auth_init_trustdomain(struct auth_context *auth_context, const char* pa (*auth_method)->auth = check_trustdomain_security; return NT_STATUS_OK; } + +int auth_domain_init(void) +{ + smb_register_auth("trustdomain", auth_init_trustdomain, AUTH_INTERFACE_VERSION); + smb_register_auth("ntdomain", auth_init_ntdomain, AUTH_INTERFACE_VERSION); + return True; +} diff --git a/source3/auth/auth_rhosts.c b/source3/auth/auth_rhosts.c index 5451f7d930..db37193579 100644 --- a/source3/auth/auth_rhosts.c +++ b/source3/auth/auth_rhosts.c @@ -242,3 +242,10 @@ NTSTATUS auth_init_rhosts(struct auth_context *auth_context, const char *param, (*auth_method)->name = "rhosts"; return NT_STATUS_OK; } + +int auth_rhosts_init(void) +{ + smb_register_auth("rhosts", auth_init_rhosts, AUTH_INTERFACE_VERSION); + smb_register_auth("hostsequiv", auth_init_hostsequiv, AUTH_INTERFACE_VERSION); + return True; +} diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c index 48fabba0a2..aa399f33e2 100644 --- a/source3/auth/auth_sam.c +++ b/source3/auth/auth_sam.c @@ -562,3 +562,11 @@ NTSTATUS auth_init_samstrict_dc(struct auth_context *auth_context, const char *p (*auth_method)->name = "samstrict_dc"; return NT_STATUS_OK; } + +int auth_sam_init(void) +{ + smb_register_auth("samstrict_dc", auth_init_samstrict_dc, AUTH_INTERFACE_VERSION); + smb_register_auth("samstrict", auth_init_samstrict, AUTH_INTERFACE_VERSION); + smb_register_auth("sam", auth_init_sam, AUTH_INTERFACE_VERSION); + return True; +} diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c index 5144852d3b..a311f01dc3 100644 --- a/source3/auth/auth_server.c +++ b/source3/auth/auth_server.c @@ -400,3 +400,8 @@ NTSTATUS auth_init_smbserver(struct auth_context *auth_context, const char* para (*auth_method)->free_private_data = free_server_private_data; return NT_STATUS_OK; } + +int auth_server_init(void) +{ + return smb_register_auth("smbserver", auth_init_smbserver, AUTH_INTERFACE_VERSION); +} diff --git a/source3/auth/auth_unix.c b/source3/auth/auth_unix.c index 4f44767a81..efab2046c3 100644 --- a/source3/auth/auth_unix.c +++ b/source3/auth/auth_unix.c @@ -130,3 +130,7 @@ NTSTATUS auth_init_unix(struct auth_context *auth_context, const char* param, au return NT_STATUS_OK; } +int auth_unix_init(void) +{ + return smb_register_auth("unix", auth_init_unix, AUTH_INTERFACE_VERSION); +} diff --git a/source3/auth/auth_winbind.c b/source3/auth/auth_winbind.c index 5e1567d3c1..e2a292dd01 100644 --- a/source3/auth/auth_winbind.c +++ b/source3/auth/auth_winbind.c @@ -134,3 +134,8 @@ NTSTATUS auth_init_winbind(struct auth_context *auth_context, const char *param, (*auth_method)->auth = check_winbind_security; return NT_STATUS_OK; } + +int auth_winbind_init(void) +{ + return smb_register_auth("winbind", auth_init_winbind, AUTH_INTERFACE_VERSION); +} diff --git a/source3/configure.in b/source3/configure.in index 0c8301d1da..4a1ed3ab4b 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -239,7 +239,7 @@ AC_VALIDATE_CACHE_SYSTEM_TYPE DYNEXP= dnl Add modules that have to be built by default here -default_modules="pdb_smbpasswd pdb_tdbsam pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss" +default_modules="pdb_smbpasswd pdb_tdbsam pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin" # # Config CPPFLAG settings for strange OS's that must be set @@ -3377,10 +3377,10 @@ SMB_MODULE(pdb_guest, passdb/pdb_guest.o, bin/guest.so, PDB) SMB_SUBSYSTEM(PDB) SMB_MODULE(rpc_lsa, \$(RPC_LSA_OBJ), bin/librpc_lsarpc.so, RPC) -SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), bin/librpc_reg.so, RPC) -SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), bin/librpc_wks.so, RPC) -SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), bin/librpc_netlog.so, RPC) -SMB_MODULE(rpc_dfs, \$(RPC_DFS_OBJ), bin/librpc_dfs.so, RPC) +SMB_MODULE(rpc_reg, \$(RPC_REG_OBJ), bin/librpc_winreg.so, RPC) +SMB_MODULE(rpc_wks, \$(RPC_WKS_OBJ), bin/librpc_wkssvc.so, RPC) +SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), bin/librpc_NETLOGON.so, RPC) +SMB_MODULE(rpc_dfs, \$(RPC_DFS_OBJ), bin/librpc_netdfs.so, RPC) SMB_MODULE(rpc_srv, \$(RPC_SVC_OBJ), bin/librpc_srvsvc.so, RPC) SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), bin/librpc_spoolss.so, RPC) SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), bin/librpc_samr.so, RPC) @@ -3389,6 +3389,15 @@ SMB_SUBSYSTEM(RPC) SMB_MODULE(charset_weird, modules/developer.o, bin/developer.so, CHARSET) SMB_SUBSYSTEM(CHARSET) +SMB_MODULE(auth_rhosts, auth/auth_rhosts.o, bin/rhosts.so, AUTH) +SMB_MODULE(auth_sam, auth/auth_sam.o, bin/sam.so, AUTH) +SMB_MODULE(auth_unix, auth/auth_unix.o, bin/unix.so, AUTH) +SMB_MODULE(auth_winbind, auth/auth_winbind.o, bin/winbind.so, AUTH) +SMB_MODULE(auth_server, auth/auth_server.o, bin/server.so, AUTH) +SMB_MODULE(auth_domain, auth/auth_domain.o, bin/domain.so, AUTH) +SMB_MODULE(auth_builtin, auth/auth_builtin.o, bin/builtin.so, AUTH) +SMB_SUBSYSTEM(AUTH) + ################################################# # do extra things if we are running insure diff --git a/source3/include/auth.h b/source3/include/auth.h index e37f181082..626b9f3ba0 100644 --- a/source3/include/auth.h +++ b/source3/include/auth.h @@ -148,6 +148,8 @@ struct auth_init_function_entry { /* Function to create a member of the authmethods list */ auth_init_function init; + + struct auth_init_function_entry *prev, *next; }; typedef struct auth_ntlmssp_state @@ -158,4 +160,6 @@ typedef struct auth_ntlmssp_state struct ntlmssp_state *ntlmssp_state; } AUTH_NTLMSSP_STATE; +#define AUTH_INTERFACE_VERSION 1 + #endif /* _SMBAUTH_H_ */ -- cgit From b7c4fa4cc6c8b9737f8657dace58042e135d8e44 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 25 Mar 2003 04:19:04 +0000 Subject: win9x was suffered a case of the blues during a domain logon. For some reason, explicitly setting the service type during the tcon&X fixes this. (This used to be commit c458179d21465165705e6c035776698cb824baf5) --- source3/smbd/reply.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 715bace152..1a1c84efed 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -272,9 +272,22 @@ int reply_tcon_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt } else { /* NT sets the fstype of IPC$ to the null string */ const char *fsname = IS_IPC(conn) ? "" : lp_fstype(SNUM(conn)); + const char *devicetype; set_message(outbuf,3,0,True); - + + if ( IS_IPC(conn) ) + devicetype = "IPC"; + else if ( IS_PRINT(conn) ) + devicetype = "LPT:"; + else + devicetype = "A:"; + + p = smb_buf(outbuf); + p += srvstr_push(outbuf, p, IS_IPC(conn) ? "IPC" : devicetype, -1, + STR_TERMINATE|STR_ASCII); + p += srvstr_push(outbuf, p, fsname, -1, + STR_TERMINATE); p = smb_buf(outbuf); p += srvstr_push(outbuf, p, IS_IPC(conn) ? "IPC" : devicename, -1, STR_TERMINATE|STR_ASCII); -- cgit From 25cdc523ed7b60964bf57c4745bafc74799f099b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 25 Mar 2003 07:54:34 +0000 Subject: Apply metze's change correctly this time. Playing 'patch' by hand can be somewhat error-prone.. Volker (This used to be commit 12fabd07148c21f5481cb750f1cfdab2e8112e4b) --- source3/passdb/pdb_ldap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index a7a168fe64..c54095b250 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -2187,6 +2187,12 @@ static BOOL init_group_from_ldap(struct ldapsam_privates *ldap_state, temp)) { DEBUG(3, ("Attribute displayName not found\n")); temp[0] = '\0'; + if (!get_single_attribute(ldap_state->ldap_struct, entry, "cn", + temp)) { + DEBUG(0, ("Attributes cn not found either " + "for gidNumber(%i)\n",map->gid)); + return False; + } } fstrcpy(map->nt_name, temp); @@ -2194,12 +2200,6 @@ static BOOL init_group_from_ldap(struct ldapsam_privates *ldap_state, temp)) { DEBUG(3, ("Attribute description not found\n")); temp[0] = '\0'; - if (!get_single_attribute(ldap_state->ldap_struct, entry, "cn", - temp)) { - DEBUG(0, ("Attributes cn not found either " - "for gidNumber(%i)\n",map->gid)); - return False; - } } fstrcpy(map->comment, temp); -- cgit From fc64b4c00077f5a6c307e14590adbda0f9a6bee8 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 25 Mar 2003 07:55:10 +0000 Subject: Make these functions static, keep them out of proto. (This used to be commit 34934d2edf0d575fae7d729fe4d8d3ab034a544f) --- source3/modules/vfs_recycle.c | 2 +- source3/modules/xml.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index a99a593caf..ba453bad2c 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -610,7 +610,7 @@ static int recycle_unlink(connection_struct *conn, const char *file_name) final_name = NULL; asprintf(&final_name, "%s/%s", temp_name, base); ALLOC_CHECK(final_name, done); - DEBUG(10, ("recycle.bin: recycled file name%s\n", temp_name)); /* new filename with path */ + DEBUG(10, ("recycle.bin: recycled file name: %s\n", temp_name)); /* new filename with path */ /* check if we should delete file from recycle bin */ if (recycle_file_exist(conn, final_name)) { diff --git a/source3/modules/xml.c b/source3/modules/xml.c index 85b9e81b7f..1a4aeeeac0 100644 --- a/source3/modules/xml.c +++ b/source3/modules/xml.c @@ -47,7 +47,7 @@ static char * iota(int a) { return tmp; } -BOOL parsePass(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, SAM_ACCOUNT * u) +static BOOL parsePass(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, SAM_ACCOUNT * u) { pstring temp; @@ -76,7 +76,7 @@ BOOL parsePass(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, SAM_ACCOUNT * u) return True; } -BOOL parseUser(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, SAM_ACCOUNT * u) +static BOOL parseUser(xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, SAM_ACCOUNT * u) { char *tmp; DOM_SID sid; @@ -245,7 +245,7 @@ typedef struct pdb_xml { xmlNsPtr ns; } pdb_xml; -xmlNodePtr parseSambaXMLFile(struct pdb_xml *data) +static xmlNodePtr parseSambaXMLFile(struct pdb_xml *data) { xmlNodePtr cur; -- cgit From 910da34e6db73e24bd93176c80a3fd9908bd870a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 25 Mar 2003 09:47:52 +0000 Subject: Make auth.c compile again. I'm not sure what this does though... Volker (This used to be commit 8e3f300f21e23b7e6b68ddcc45d581a962cd8aa4) --- source3/auth/auth.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/auth/auth.c b/source3/auth/auth.c index 4416f93fba..f9df255595 100644 --- a/source3/auth/auth.c +++ b/source3/auth/auth.c @@ -361,13 +361,14 @@ static NTSTATUS make_auth_context_text_list(struct auth_context **auth_context, } for (;*text_list; text_list++) { - DEBUG(5,("make_auth_context_text_list: Attempting to find an auth method to match %s\n", - *text_list)); struct auth_init_function_entry *entry; char *module_name = smb_xstrdup(*text_list); char *module_params = NULL; char *p; + DEBUG(5,("make_auth_context_text_list: Attempting to find an auth method to match %s\n", + *text_list)); + p = strchr(module_name, ':'); if (p) { *p = 0; -- cgit From c0efc3536f9b4dcb9978b198d4b143267948da36 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 25 Mar 2003 10:29:22 +0000 Subject: Fix debug (thanks metze) Andrew Bartlett (This used to be commit 5562f1865c90e3f52a3178d9d9ded60909bbe5f0) --- source3/libsmb/ntlmssp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/ntlmssp.c b/source3/libsmb/ntlmssp.c index 0cd1ac33ec..d54655d17f 100644 --- a/source3/libsmb/ntlmssp.c +++ b/source3/libsmb/ntlmssp.c @@ -385,7 +385,7 @@ NTSTATUS ntlmssp_server_update(NTLMSSP_STATE *ntlmssp_state, } else if (ntlmssp_command == NTLMSSP_AUTH) { return ntlmssp_server_auth(ntlmssp_state, request, reply); } else { - DEBUG(1, ("unknown NTLMSSP command %u\n", ntlmssp_command, ntlmssp_state->expected_state)); + DEBUG(1, ("unknown NTLMSSP command %u, expected %u\n", ntlmssp_command, ntlmssp_state->expected_state)); return NT_STATUS_INVALID_PARAMETER; } } -- cgit From 5ee88b189118e01fa7d92e4d3ee0b1f6f878ea7c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 10:37:58 +0000 Subject: We need to 'preprocess' in popt_common_samba as well (This used to be commit 37ee8aecf4ae570c3d08e9fa94724bc9c917108f) --- source3/lib/popt_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index edd54c13d5..6920ef4d5f 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -123,7 +123,7 @@ struct poptOption popt_common_connection[] = { }; struct poptOption popt_common_samba[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, -- cgit From 49871190206ea4fc693f4f346c09cf0c838df072 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 12:05:23 +0000 Subject: Remove obsolete defines (because of new modules system). We need a way to track which modules have been builtin (This used to be commit 0f724be38439af9284e51b7b9b8605e8956e51ba) --- source3/smbd/build_options.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'source3') diff --git a/source3/smbd/build_options.c b/source3/smbd/build_options.c index da5accebab..bedfb5ef73 100644 --- a/source3/smbd/build_options.c +++ b/source3/smbd/build_options.c @@ -104,15 +104,6 @@ void build_options(BOOL screen) #ifdef WITH_PAM output(screen," WITH_PAM\n"); #endif -#ifdef WITH_TDB_SAM - output(screen," WITH_TDB_SAM\n"); -#endif -#ifdef WITH_SMBPASSWD_SAM - output(screen," WITH_SMBPASSWD_SAM\n"); -#endif -#ifdef WITH_NISPLUS_SAM - output(screen," WITH_NISPLUS_SAM\n"); -#endif #ifdef WITH_NISPLUS_HOME output(screen," WITH_NISPLUS_HOME\n"); #endif -- cgit From e520d4be5e30c7dcbabbed7438079dc5805a13a0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 12:27:09 +0000 Subject: Print list of builtin modules in 'smbd -b' (This used to be commit 3a2ed0da40c9709cdae061927f44a38f58e44df0) --- source3/aclocal.m4 | 1 + source3/configure.in | 2 ++ source3/smbd/build_options.c | 3 +++ 3 files changed, 6 insertions(+) (limited to 'source3') diff --git a/source3/aclocal.m4 b/source3/aclocal.m4 index 5d9070fcd9..744acf6a1b 100644 --- a/source3/aclocal.m4 +++ b/source3/aclocal.m4 @@ -55,6 +55,7 @@ AC_DEFUN(SMB_MODULE, AC_MSG_RESULT([shared]) elif test x"$DEST" = xSTATIC; then [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z]) $1_init();" + string_static_modules="$string_static_modules $1" $4_STATIC="$$4_STATIC $2" AC_SUBST($4_STATIC) AC_MSG_RESULT([static]) diff --git a/source3/configure.in b/source3/configure.in index 4a1ed3ab4b..a6d078c8ce 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3398,6 +3398,8 @@ SMB_MODULE(auth_domain, auth/auth_domain.o, bin/domain.so, AUTH) SMB_MODULE(auth_builtin, auth/auth_builtin.o, bin/builtin.so, AUTH) SMB_SUBSYSTEM(AUTH) +AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) + ################################################# # do extra things if we are running insure diff --git a/source3/smbd/build_options.c b/source3/smbd/build_options.c index bedfb5ef73..43335666a6 100644 --- a/source3/smbd/build_options.c +++ b/source3/smbd/build_options.c @@ -523,6 +523,9 @@ void build_options(BOOL screen) output(screen," sizeof(uint32): %d\n",sizeof(uint32)); output(screen," sizeof(short): %d\n",sizeof(short)); output(screen," sizeof(void*): %d\n",sizeof(void*)); + + output(screen,"\nBuiltin modules:\n"); + output(screen,"%s\n", STRING_STATIC_MODULES); } -- cgit From f97934e3f517ecf0e894763c4e1156d3ebd77686 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 13:40:34 +0000 Subject: Make variables static to satisfy exotic compilers (This used to be commit 094eed2c6222fe167ee9f596f4b849a4dea234bf) --- source3/utils/nmblookup.c | 4 ++-- source3/utils/testparm.c | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/utils/nmblookup.c b/source3/utils/nmblookup.c index 85f092c8b0..31c7967a07 100644 --- a/source3/utils/nmblookup.c +++ b/source3/utils/nmblookup.c @@ -187,8 +187,8 @@ int main(int argc,char *argv[]) int opt; unsigned int lookup_type = 0x0; fstring lookup; - BOOL find_master=False; - BOOL lookup_by_ip = False; + static BOOL find_master=False; + static BOOL lookup_by_ip = False; poptContext pc; struct poptOption long_options[] = { diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 4c8a2ccf63..e8dd3c15b2 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -192,7 +192,6 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ int s; static BOOL silent_mode = False; int ret = 0; - int opt; poptContext pc; static const char *term_code = ""; static char *new_local_machine = NULL; -- cgit From bdd96341f1116dd67a24447ed672f7235b518c46 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 13:59:55 +0000 Subject: Don't use 'opt' (This used to be commit 6ab41e50fd0a36ebd9969064aa46235dc687dfba) --- source3/utils/testparm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index e8dd3c15b2..e3d6ce0274 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -213,7 +213,7 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ POPT_CONTEXT_KEEP_FIRST); poptSetOtherOptionHelp(pc, "[OPTION...] [host-name] [host-ip]"); - while((opt = poptGetNextOpt(pc)) != -1); + while(poptGetNextOpt(pc) != -1); setup_logging(poptGetArg(pc), True); -- cgit From 4905ba282fc1692b74208b177e934cdebd447c66 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 14:46:11 +0000 Subject: - Support building all auth modules as .so's - Change 2 variable names to avoid conflicts (patch by Stephan Kulow ) (This used to be commit 71b05cd14ae6df8340730e7bad1c783dc278c5d3) --- source3/Makefile.in | 41 +++++++++++++++++++++++-- source3/auth/auth_domain.c | 2 +- source3/configure.in | 14 ++++----- source3/libads/ldap.c | 66 +++++++++++++++++++-------------------- source3/libads/ldap_utils.c | 10 +++--- source3/rpc_parse/parse_misc.c | 70 +++++++++++++++++++++--------------------- source3/smbd/process.c | 2 +- 7 files changed, 120 insertions(+), 85 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index daf495c25e..95a4cee98f 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -295,9 +295,16 @@ PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o UNIGRP_OBJ = libsmb/netlogon_unigrp.o -AUTH_OBJ = auth/auth.o auth/auth_sam.o auth/auth_server.o auth/auth_domain.o \ - auth/auth_rhosts.o auth/auth_unix.o auth/auth_util.o auth/auth_winbind.o \ - auth/auth_builtin.o auth/auth_compat.o auth/auth_ntlmssp.o \ +AUTH_BUILTIN_OBJ = auth/auth_builtin.o +AUTH_DOMAIN_OBJ = auth/auth_domain.o +AUTH_SAM_OBJ = auth/auth_sam.o +AUTH_RHOSTS_OBJ = auth/auth_rhosts.o +AUTH_SERVER_OBJ = auth/auth_server.o +AUTH_UNIX_OBJ = auth/auth_unix.o +AUTH_WINBIND_OBJ = auth/auth_winbind.o + +AUTH_OBJ = auth/auth.o @AUTH_STATIC@ auth/auth_util.o auth/auth_compat.o \ + auth/auth_ntlmssp.o \ $(PLAINTEXT_AUTH_OBJ) $(UNIGRP_OBJ) MANGLE_OBJ = smbd/mangle.o smbd/mangle_hash.o smbd/mangle_map.o smbd/mangle_hash2.o @@ -945,6 +952,34 @@ nsswitch/pam_winbind.@SHLIBEXT@: $(PAM_WINBIND_OBJ) bin/.dummy @$(SHLD) $(LDSHFLAGS) -o $@ $(PAM_WINBIND_OBJ) \ @SONAMEFLAG@`basename $@` -lpam +bin/rhosts.@SHLIBEXT@: $(AUTH_RHOSTS_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(AUTH_RHOSTS_OBJ) @SONAMEFLAG@`basename $@` + +bin/builtin.@SHLIBEXT@: $(AUTH_BUILTIN_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(AUTH_BUILTIN_OBJ) @SONAMEFLAG@`basename $@` + +bin/domain.@SHLIBEXT@: $(AUTH_DOMAIN_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(AUTH_DOMAIN_OBJ) @SONAMEFLAG@`basename $@` + +bin/server.@SHLIBEXT@: $(AUTH_SERVER_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(AUTH_SERVER_OBJ) @SONAMEFLAG@`basename $@` + +bin/winbind.@SHLIBEXT@: $(AUTH_WINBIND_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(AUTH_WINBIND_OBJ) @SONAMEFLAG@`basename $@` + +bin/unix.@SHLIBEXT@: $(AUTH_UNIX_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(AUTH_UNIX_OBJ) @SONAMEFLAG@`basename $@` + +bin/sam.@SHLIBEXT@: $(AUTH_SAM_OBJ) + @echo "Building plugin $@" + @$(SHLD) $(LDSHFLAGS) -o $@ $(AUTH_SAM_OBJ) @SONAMEFLAG@`basename $@` + bin/mysql.@SHLIBEXT@: $(MYSQL_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(MYSQL_OBJ) @MYSQL_LIBS@ \ diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index 9ca2f4e190..256c4532ed 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -24,7 +24,7 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_AUTH -BOOL global_machine_password_needs_changing = False; +extern BOOL global_machine_password_needs_changing; extern userdom_struct current_user_info; diff --git a/source3/configure.in b/source3/configure.in index a6d078c8ce..3b940f08d9 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3389,13 +3389,13 @@ SMB_SUBSYSTEM(RPC) SMB_MODULE(charset_weird, modules/developer.o, bin/developer.so, CHARSET) SMB_SUBSYSTEM(CHARSET) -SMB_MODULE(auth_rhosts, auth/auth_rhosts.o, bin/rhosts.so, AUTH) -SMB_MODULE(auth_sam, auth/auth_sam.o, bin/sam.so, AUTH) -SMB_MODULE(auth_unix, auth/auth_unix.o, bin/unix.so, AUTH) -SMB_MODULE(auth_winbind, auth/auth_winbind.o, bin/winbind.so, AUTH) -SMB_MODULE(auth_server, auth/auth_server.o, bin/server.so, AUTH) -SMB_MODULE(auth_domain, auth/auth_domain.o, bin/domain.so, AUTH) -SMB_MODULE(auth_builtin, auth/auth_builtin.o, bin/builtin.so, AUTH) +SMB_MODULE(auth_rhosts, \$(AUTH_RHOSTS_OBJ), bin/rhosts.so, AUTH) +SMB_MODULE(auth_sam, \$(AUTH_SAM_OBJ), bin/sam.so, AUTH) +SMB_MODULE(auth_unix, \$(AUTH_UNIX_OBJ), bin/unix.so, AUTH) +SMB_MODULE(auth_winbind, \$(AUTH_WINBIND_OBJ), bin/winbind.so, AUTH) +SMB_MODULE(auth_server, \$(AUTH_SERVER_OBJ), bin/server.so, AUTH) +SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), bin/domain.so, AUTH) +SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), bin/builtin.so, AUTH) SMB_SUBSYSTEM(AUTH) AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 67827d27f3..baedfb28db 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -401,7 +401,7 @@ static char **ads_pull_strvals(TALLOC_CTX *ctx, const char **in_vals) * @param ads connection to ads server * @param bind_path Base dn for the search * @param scope Scope of search (LDAP_BASE | LDAP_ONE | LDAP_SUBTREE) - * @param exp Search expression - specified in local charset + * @param expr Search expression - specified in local charset * @param attrs Attributes to retrieve - specified in utf8 or ascii * @param res ** which will contain results - free res* with ads_msgfree() * @param count Number of entries retrieved on this page @@ -409,12 +409,12 @@ static char **ads_pull_strvals(TALLOC_CTX *ctx, const char **in_vals) * @return status of search **/ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path, - int scope, const char *exp, + int scope, const char *expr, const char **attrs, void **res, int *count, void **cookie) { int rc, i, version; - char *utf8_exp, *utf8_path, **search_attrs; + char *utf8_expr, *utf8_path, **search_attrs; LDAPControl PagedResults, NoReferrals, *controls[3], **rcontrols; BerElement *cookie_be = NULL; struct berval *cookie_bv= NULL; @@ -428,7 +428,7 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path, /* 0 means the conversion worked but the result was empty so we only fail if it's -1. In any case, it always at least nulls out the dest */ - if ((push_utf8_talloc(ctx, &utf8_exp, exp) == (size_t)-1) || + if ((push_utf8_talloc(ctx, &utf8_expr, expr) == (size_t)-1) || (push_utf8_talloc(ctx, &utf8_path, bind_path) == (size_t)-1)) { rc = LDAP_NO_MEMORY; goto done; @@ -489,7 +489,7 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path, */ ldap_set_option(ads->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF); - rc = ldap_search_ext_s(ads->ld, utf8_path, scope, utf8_exp, + rc = ldap_search_ext_s(ads->ld, utf8_path, scope, utf8_expr, search_attrs, 0, controls, NULL, NULL, LDAP_NO_LIMIT, (LDAPMessage **)res); @@ -497,7 +497,7 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path, ber_bvfree(cookie_bv); if (rc) { - DEBUG(3,("ldap_search_ext_s(%s) -> %s\n", exp, ldap_err2string(rc))); + DEBUG(3,("ldap_search_ext_s(%s) -> %s\n", expr, ldap_err2string(rc))); goto done; } @@ -541,20 +541,20 @@ done: * @param ads connection to ads server * @param bind_path Base dn for the search * @param scope Scope of search (LDAP_BASE | LDAP_ONE | LDAP_SUBTREE) - * @param exp Search expression + * @param expr Search expression * @param attrs Attributes to retrieve * @param res ** which will contain results - free res* with ads_msgfree() * @return status of search **/ ADS_STATUS ads_do_search_all(ADS_STRUCT *ads, const char *bind_path, - int scope, const char *exp, + int scope, const char *expr, const char **attrs, void **res) { void *cookie = NULL; int count = 0; ADS_STATUS status; - status = ads_do_paged_search(ads, bind_path, scope, exp, attrs, res, + status = ads_do_paged_search(ads, bind_path, scope, expr, attrs, res, &count, &cookie); if (!ADS_ERR_OK(status)) return status; @@ -564,7 +564,7 @@ ADS_STATUS ads_do_search_all(ADS_STRUCT *ads, const char *bind_path, ADS_STATUS status2; LDAPMessage *msg, *next; - status2 = ads_do_paged_search(ads, bind_path, scope, exp, + status2 = ads_do_paged_search(ads, bind_path, scope, expr, attrs, &res2, &count, &cookie); if (!ADS_ERR_OK(status2)) break; @@ -588,14 +588,14 @@ ADS_STATUS ads_do_search_all(ADS_STRUCT *ads, const char *bind_path, * @param ads connection to ads server * @param bind_path Base dn for the search * @param scope Scope of search (LDAP_BASE | LDAP_ONE | LDAP_SUBTREE) - * @param exp Search expression - specified in local charset + * @param expr Search expression - specified in local charset * @param attrs Attributes to retrieve - specified in UTF-8 or ascii * @param fn Function which takes attr name, values list, and data_area * @param data_area Pointer which is passed to function on each call * @return status of search **/ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path, - int scope, const char *exp, const char **attrs, + int scope, const char *expr, const char **attrs, BOOL(*fn)(char *, void **, void *), void *data_area) { @@ -604,7 +604,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path, ADS_STATUS status; void *res; - status = ads_do_paged_search(ads, bind_path, scope, exp, attrs, &res, + status = ads_do_paged_search(ads, bind_path, scope, expr, attrs, &res, &count, &cookie); if (!ADS_ERR_OK(status)) return status; @@ -613,7 +613,7 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path, ads_msgfree(ads, res); while (cookie) { - status = ads_do_paged_search(ads, bind_path, scope, exp, attrs, + status = ads_do_paged_search(ads, bind_path, scope, expr, attrs, &res, &count, &cookie); if (!ADS_ERR_OK(status)) break; @@ -630,18 +630,18 @@ ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path, * @param ads connection to ads server * @param bind_path Base dn for the search * @param scope Scope of search (LDAP_BASE | LDAP_ONE | LDAP_SUBTREE) - * @param exp Search expression + * @param expr Search expression * @param attrs Attributes to retrieve * @param res ** which will contain results - free res* with ads_msgfree() * @return status of search **/ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope, - const char *exp, + const char *expr, const char **attrs, void **res) { struct timeval timeout; int rc; - char *utf8_exp, *utf8_path, **search_attrs = NULL; + char *utf8_expr, *utf8_path, **search_attrs = NULL; TALLOC_CTX *ctx; if (!(ctx = talloc_init("ads_do_search"))) { @@ -652,7 +652,7 @@ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope, /* 0 means the conversion worked but the result was empty so we only fail if it's negative. In any case, it always at least nulls out the dest */ - if ((push_utf8_talloc(ctx, &utf8_exp, exp) == (size_t)-1) || + if ((push_utf8_talloc(ctx, &utf8_expr, expr) == (size_t)-1) || (push_utf8_talloc(ctx, &utf8_path, bind_path) == (size_t)-1)) { DEBUG(1,("ads_do_search: push_utf8_talloc() failed!")); rc = LDAP_NO_MEMORY; @@ -679,7 +679,7 @@ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope, /* see the note in ads_do_paged_search - we *must* disable referrals */ ldap_set_option(ads->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF); - rc = ldap_search_ext_s(ads->ld, utf8_path, scope, utf8_exp, + rc = ldap_search_ext_s(ads->ld, utf8_path, scope, utf8_expr, search_attrs, 0, NULL, NULL, &timeout, LDAP_NO_LIMIT, (LDAPMessage **)res); @@ -698,16 +698,16 @@ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope, * Do a general ADS search * @param ads connection to ads server * @param res ** which will contain results - free res* with ads_msgfree() - * @param exp Search expression + * @param expr Search expression * @param attrs Attributes to retrieve * @return status of search **/ ADS_STATUS ads_search(ADS_STRUCT *ads, void **res, - const char *exp, + const char *expr, const char **attrs) { return ads_do_search(ads, ads->config.bind_path, LDAP_SCOPE_SUBTREE, - exp, attrs, res); + expr, attrs, res); } /** @@ -772,18 +772,18 @@ char *ads_get_dn(ADS_STRUCT *ads, void *res) ADS_STATUS ads_find_machine_acct(ADS_STRUCT *ads, void **res, const char *host) { ADS_STATUS status; - char *exp; + char *expr; const char *attrs[] = {"*", "nTSecurityDescriptor", NULL}; /* the easiest way to find a machine account anywhere in the tree is to look for hostname$ */ - if (asprintf(&exp, "(samAccountName=%s$)", host) == -1) { + if (asprintf(&expr, "(samAccountName=%s$)", host) == -1) { DEBUG(1, ("asprintf failed!\n")); return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); } - status = ads_search(ads, res, exp, attrs); - free(exp); + status = ads_search(ads, res, expr, attrs); + free(expr); return status; } @@ -1424,7 +1424,7 @@ ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname) ADS_STATUS ads_set_machine_sd(ADS_STRUCT *ads, const char *hostname, char *dn) { const char *attrs[] = {"nTSecurityDescriptor", "objectSid", 0}; - char *exp = 0; + char *expr = 0; size_t sd_size = 0; struct berval bval = {0, NULL}; prs_struct ps_wire; @@ -1452,7 +1452,7 @@ ADS_STATUS ads_set_machine_sd(ADS_STRUCT *ads, const char *hostname, char *dn) return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); } - if (asprintf(&exp, "(samAccountName=%s$)", escaped_hostname) == -1) { + if (asprintf(&expr, "(samAccountName=%s$)", escaped_hostname) == -1) { DEBUG(1, ("ads_set_machine_sd: asprintf failed!\n")); SAFE_FREE(escaped_hostname); return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); @@ -1460,7 +1460,7 @@ ADS_STATUS ads_set_machine_sd(ADS_STRUCT *ads, const char *hostname, char *dn) SAFE_FREE(escaped_hostname); - ret = ads_search(ads, (void *) &res, exp, attrs); + ret = ads_search(ads, (void *) &res, expr, attrs); if (!ADS_ERR_OK(ret)) return ret; @@ -2036,7 +2036,7 @@ but you need to force the bind path to match the configurationNamingContext from */ ADS_STATUS ads_workgroup_name(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char **workgroup) { - char *exp; + char *expr; ADS_STATUS rc; char **principles; char *prefix; @@ -2047,10 +2047,10 @@ ADS_STATUS ads_workgroup_name(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char **workg (*workgroup) = NULL; - asprintf(&exp, "(&(objectclass=computer)(dnshostname=%s.%s))", + asprintf(&expr, "(&(objectclass=computer)(dnshostname=%s.%s))", ads->config.ldap_server_name, ads->config.realm); - rc = ads_search(ads, &res, exp, attrs); - free(exp); + rc = ads_search(ads, &res, expr, attrs); + free(expr); if (!ADS_ERR_OK(rc)) { return rc; diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c index 907f7c8aff..6855600288 100644 --- a/source3/libads/ldap_utils.c +++ b/source3/libads/ldap_utils.c @@ -28,7 +28,7 @@ this is supposed to catch dropped connections and auto-reconnect */ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope, - const char *exp, + const char *expr, const char **attrs, void **res) { ADS_STATUS status; @@ -46,10 +46,10 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); while (count--) { - status = ads_do_search_all(ads, bp, scope, exp, attrs, res); + status = ads_do_search_all(ads, bp, scope, expr, attrs, res); if (ADS_ERR_OK(status)) { DEBUG(5,("Search for %s gave %d replies\n", - exp, ads_count_replies(ads, *res))); + expr, ads_count_replies(ads, *res))); free(bp); return status; } @@ -79,11 +79,11 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope ADS_STATUS ads_search_retry(ADS_STRUCT *ads, void **res, - const char *exp, + const char *expr, const char **attrs) { return ads_do_search_retry(ads, ads->config.bind_path, LDAP_SCOPE_SUBTREE, - exp, attrs, res); + expr, attrs, res); } ADS_STATUS ads_search_retry_dn(ADS_STRUCT *ads, void **res, diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index b7b0e9346b..a39e3391bb 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -1289,22 +1289,22 @@ void init_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid) Inits a DOM_CLNT_SRV structure. ********************************************************************/ -static void init_clnt_srv(DOM_CLNT_SRV *log, const char *logon_srv, const char *comp_name) +static void init_clnt_srv(DOM_CLNT_SRV *dlog, const char *logon_srv, const char *comp_name) { DEBUG(5,("init_clnt_srv: %d\n", __LINE__)); if (logon_srv != NULL) { - log->undoc_buffer = 1; - init_unistr2(&log->uni_logon_srv, logon_srv, strlen(logon_srv)+1); + dlog->undoc_buffer = 1; + init_unistr2(&dlog->uni_logon_srv, logon_srv, strlen(logon_srv)+1); } else { - log->undoc_buffer = 0; + dlog->undoc_buffer = 0; } if (comp_name != NULL) { - log->undoc_buffer2 = 1; - init_unistr2(&log->uni_comp_name, comp_name, strlen(comp_name)+1); + dlog->undoc_buffer2 = 1; + init_unistr2(&dlog->uni_comp_name, comp_name, strlen(comp_name)+1); } else { - log->undoc_buffer2 = 0; + dlog->undoc_buffer2 = 0; } } @@ -1312,9 +1312,9 @@ static void init_clnt_srv(DOM_CLNT_SRV *log, const char *logon_srv, const char * Inits or writes a DOM_CLNT_SRV structure. ********************************************************************/ -static BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int depth) +static BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *dlog, prs_struct *ps, int depth) { - if (log == NULL) + if (dlog == NULL) return False; prs_debug(ps, depth, desc, "smb_io_clnt_srv"); @@ -1323,22 +1323,22 @@ static BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *log, prs_struct *ps, if(!prs_align(ps)) return False; - if(!prs_uint32("undoc_buffer ", ps, depth, &log->undoc_buffer)) + if(!prs_uint32("undoc_buffer ", ps, depth, &dlog->undoc_buffer)) return False; - if (log->undoc_buffer != 0) { - if(!smb_io_unistr2("unistr2", &log->uni_logon_srv, log->undoc_buffer, ps, depth)) + if (dlog->undoc_buffer != 0) { + if(!smb_io_unistr2("unistr2", &dlog->uni_logon_srv, dlog->undoc_buffer, ps, depth)) return False; } if(!prs_align(ps)) return False; - if(!prs_uint32("undoc_buffer2", ps, depth, &log->undoc_buffer2)) + if(!prs_uint32("undoc_buffer2", ps, depth, &dlog->undoc_buffer2)) return False; - if (log->undoc_buffer2 != 0) { - if(!smb_io_unistr2("unistr2", &log->uni_comp_name, log->undoc_buffer2, ps, depth)) + if (dlog->undoc_buffer2 != 0) { + if(!smb_io_unistr2("unistr2", &dlog->uni_comp_name, dlog->undoc_buffer2, ps, depth)) return False; } @@ -1349,28 +1349,28 @@ static BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *log, prs_struct *ps, Inits a DOM_LOG_INFO structure. ********************************************************************/ -void init_log_info(DOM_LOG_INFO *log, const char *logon_srv, const char *acct_name, +void init_log_info(DOM_LOG_INFO *dlog, const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name) { DEBUG(5,("make_log_info %d\n", __LINE__)); - log->undoc_buffer = 1; + dlog->undoc_buffer = 1; - init_unistr2(&log->uni_logon_srv, logon_srv, strlen(logon_srv)+1); - init_unistr2(&log->uni_acct_name, acct_name, strlen(acct_name)+1); + init_unistr2(&dlog->uni_logon_srv, logon_srv, strlen(logon_srv)+1); + init_unistr2(&dlog->uni_acct_name, acct_name, strlen(acct_name)+1); - log->sec_chan = sec_chan; + dlog->sec_chan = sec_chan; - init_unistr2(&log->uni_comp_name, comp_name, strlen(comp_name)+1); + init_unistr2(&dlog->uni_comp_name, comp_name, strlen(comp_name)+1); } /******************************************************************* Reads or writes a DOM_LOG_INFO structure. ********************************************************************/ -BOOL smb_io_log_info(const char *desc, DOM_LOG_INFO *log, prs_struct *ps, int depth) +BOOL smb_io_log_info(const char *desc, DOM_LOG_INFO *dlog, prs_struct *ps, int depth) { - if (log == NULL) + if (dlog == NULL) return False; prs_debug(ps, depth, desc, "smb_io_log_info"); @@ -1379,18 +1379,18 @@ BOOL smb_io_log_info(const char *desc, DOM_LOG_INFO *log, prs_struct *ps, int de if(!prs_align(ps)) return False; - if(!prs_uint32("undoc_buffer", ps, depth, &log->undoc_buffer)) + if(!prs_uint32("undoc_buffer", ps, depth, &dlog->undoc_buffer)) return False; - if(!smb_io_unistr2("unistr2", &log->uni_logon_srv, True, ps, depth)) + if(!smb_io_unistr2("unistr2", &dlog->uni_logon_srv, True, ps, depth)) return False; - if(!smb_io_unistr2("unistr2", &log->uni_acct_name, True, ps, depth)) + if(!smb_io_unistr2("unistr2", &dlog->uni_acct_name, True, ps, depth)) return False; - if(!prs_uint16("sec_chan", ps, depth, &log->sec_chan)) + if(!prs_uint16("sec_chan", ps, depth, &dlog->sec_chan)) return False; - if(!smb_io_unistr2("unistr2", &log->uni_comp_name, True, ps, depth)) + if(!smb_io_unistr2("unistr2", &dlog->uni_comp_name, True, ps, depth)) return False; return True; @@ -1529,21 +1529,21 @@ BOOL smb_io_clnt_info(const char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, in Inits a DOM_LOGON_ID structure. ********************************************************************/ -void init_logon_id(DOM_LOGON_ID *log, uint32 log_id_low, uint32 log_id_high) +void init_logon_id(DOM_LOGON_ID *dlog, uint32 log_id_low, uint32 log_id_high) { DEBUG(5,("make_logon_id: %d\n", __LINE__)); - log->low = log_id_low; - log->high = log_id_high; + dlog->low = log_id_low; + dlog->high = log_id_high; } /******************************************************************* Reads or writes a DOM_LOGON_ID structure. ********************************************************************/ -BOOL smb_io_logon_id(const char *desc, DOM_LOGON_ID *log, prs_struct *ps, int depth) +BOOL smb_io_logon_id(const char *desc, DOM_LOGON_ID *dlog, prs_struct *ps, int depth) { - if (log == NULL) + if (dlog == NULL) return False; prs_debug(ps, depth, desc, "smb_io_logon_id"); @@ -1552,9 +1552,9 @@ BOOL smb_io_logon_id(const char *desc, DOM_LOGON_ID *log, prs_struct *ps, int de if(!prs_align(ps)) return False; - if(!prs_uint32("low ", ps, depth, &log->low )) + if(!prs_uint32("low ", ps, depth, &dlog->low )) return False; - if(!prs_uint32("high", ps, depth, &log->high)) + if(!prs_uint32("high", ps, depth, &dlog->high)) return False; return True; diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 16ef30c46c..de1bea493f 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -44,7 +44,7 @@ extern userdom_struct current_user_info; extern int smb_read_error; SIG_ATOMIC_T reload_after_sighup = 0; SIG_ATOMIC_T got_sig_term = 0; -extern BOOL global_machine_password_needs_changing; +BOOL global_machine_password_needs_changing = False; extern int max_send; /**************************************************************************** -- cgit From 50311f4bac526c88b11e79213c3dfdb3d44782d6 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 18:10:55 +0000 Subject: Remove old check for TDB SAM (we now have --with-{static,shared}-modules=pdb_tdbsam) (This used to be commit 760fd4e5c48276696182febcae3b0a997999b1e2) --- source3/configure.in | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 3b940f08d9..1c046e81a9 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -239,7 +239,7 @@ AC_VALIDATE_CACHE_SYSTEM_TYPE DYNEXP= dnl Add modules that have to be built by default here -default_modules="pdb_smbpasswd pdb_tdbsam pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin" +default_modules="pdb_smbpasswd pdb_tdbsam pdb_unix rpc_lsa rpc_samr rpc_reg rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_recycle vfs_audit vfs_extd_audit vfs_fake_perms vfs_netatalk" # # Config CPPFLAG settings for strange OS's that must be set @@ -2432,23 +2432,6 @@ AC_ARG_WITH(ldapsam, AC_MSG_RESULT(no) ) -################################################# -# check for a TDB password database -AC_MSG_CHECKING(whether to use TDB SAM database) -AC_ARG_WITH(tdbsam, -[ --with-tdbsam Include experimental TDB SAM support (default=no)], -[ case "$withval" in - yes) - AC_MSG_RESULT(yes) - AC_DEFINE(WITH_TDB_SAM,1,[Whether to include experimental TDB SAM support]) - ;; - *) - AC_MSG_RESULT(no) - ;; - esac ], - AC_MSG_RESULT(no) -) - ######################################################################################## ## ## END OF TESTS FOR SAM BACKENDS. @@ -3398,6 +3381,13 @@ SMB_MODULE(auth_domain, \$(AUTH_DOMAIN_OBJ), bin/domain.so, AUTH) SMB_MODULE(auth_builtin, \$(AUTH_BUILTIN_OBJ), bin/builtin.so, AUTH) SMB_SUBSYSTEM(AUTH) +SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), bin/recycle.so, VFS) +SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), bin/audit.so, VFS) +SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), bin/extd_audit.so, VFS) +SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), bin/fake_perms.so, VFS) +SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK), bin/netatalk.so, VFS) +SMB_SUBSYSTEM(VFS) + AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) ################################################# -- cgit From dc16a6848b5c3da843046a75fbd30d1cc84dd98c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 22:37:43 +0000 Subject: Always rebuild modules after running ./configure (to prevent undefined symbol errors) (This used to be commit e193b47259d11b0eaef4071acb406d6433426733) --- source3/Makefile.in | 11 ++++++++--- source3/aclocal.m4 | 5 ++++- source3/configure.in | 25 ++++++++++++++++--------- 3 files changed, 28 insertions(+), 13 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 95a4cee98f..7117281900 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -672,11 +672,11 @@ MAKEDIR = || exec false; \ # but since we also require "make install prefix=/opt/samba" *not* to # rebuild it's a bit hard. -dynconfig.o: dynconfig.c Makefile +dynconfig.o: dynconfig.c Makefile modules_clean @echo Compiling $*.c @$(CC) $(FLAGS) $(PATH_FLAGS) -c $< -o $@ -dynconfig.po: dynconfig.c Makefile +dynconfig.po: dynconfig.c Makefile modules_clean @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi @echo Compiling $*.c with @PICFLAG@ @@ -987,7 +987,7 @@ bin/mysql.@SHLIBEXT@: $(MYSQL_OBJ) bin/ldapsam.@SHLIBEXT@: passdb/pdb_ldap.o @echo "Building plugin $@" - @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_ldap.o \ + @$(SHLD) $(LDSHFLAGS) -o $@ @LDAP_LIBS@ passdb/pdb_ldap.o \ @SONAMEFLAG@`basename $@` bin/tdbsam.@SHLIBEXT@: passdb/pdb_tdb.o @@ -1188,6 +1188,11 @@ clean: delheaders python_clean -rm -f core */*~ *~ */*.o */*.po */*.po32 */*.@SHLIBEXT@ \ $(TOPFILES) $(BIN_PROGS) $(SBIN_PROGS) $(MODULES) $(TORTURE_PROGS) $(LIBSMBCLIENT) .headers.stamp +# This is quite ugly actually.. But we need to make +# sure the changes to include/config.h are used. +modules_clean: + @-rm -f @MODULES_CLEAN@ auth/auth.o passdb/pdb_interface.o rpc_server/srv_pipe_hnd.o lib/iconv.o + # Making this target will just make sure that the prototype files # exist, not necessarily that they are up to date. Since they're # removed by "make clean" this will always be run when you do anything diff --git a/source3/aclocal.m4 b/source3/aclocal.m4 index 744acf6a1b..f470e2e8b0 100644 --- a/source3/aclocal.m4 +++ b/source3/aclocal.m4 @@ -37,7 +37,7 @@ fi ]) dnl Mark specified module as shared -dnl SMB_MODULE(name,static_files,shared_files,subsystem) +dnl SMB_MODULE(name,static_files,shared_files,subsystem,whatif-static,whatif-shared) AC_DEFUN(SMB_MODULE, [ AC_MSG_CHECKING([how to build $1]) @@ -53,15 +53,18 @@ AC_DEFUN(SMB_MODULE, AC_DEFINE([$1][_init], [init_module], [Whether to build $1 as shared module]) $4_MODULES="$$4_MODULES $3" AC_MSG_RESULT([shared]) + [$6] elif test x"$DEST" = xSTATIC; then [init_static_modules_]translit([$4], [A-Z], [a-z])="$[init_static_modules_]translit([$4], [A-Z], [a-z]) $1_init();" string_static_modules="$string_static_modules $1" $4_STATIC="$$4_STATIC $2" AC_SUBST($4_STATIC) + [$5] AC_MSG_RESULT([static]) else AC_MSG_RESULT([not]) fi + MODULES_CLEAN="$MODULES_CLEAN $2 $3" ]) AC_DEFUN(SMB_SUBSYSTEM, diff --git a/source3/configure.in b/source3/configure.in index 1c046e81a9..733037b977 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2241,12 +2241,12 @@ if test x"$with_ldap_support" = x"yes"; then ################################################################## # we might need the lber lib on some systems. To avoid link errors # this test must be before the libldap test - AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"]) + AC_CHECK_LIB(lber, ber_scanf, [LDAP_LIBS="$LIBS -llber"]) ######################################################## # now see if we can find the ldap libs in standard paths if test x$have_ldap != xyes; then - AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap"; + AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LDAP_LIBS="$LIBS -lldap"; AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])]) AC_CHECK_HEADERS([ldap.h lber.h], [default_modules="$default_modules pdb_ldap"]) @@ -2260,19 +2260,21 @@ if test x"$with_ldap_support" = x"yes"; then #include ], [ldap_set_rebind_proc(0, 0, 0);], [pam_ldap_cv_ldap_set_rebind_proc=3], [pam_ldap_cv_ldap_set_rebind_proc=2]) ]) AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $pam_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc]) fi + + if test x"$with_ads_support" = x"yes"; then + LIBS="$LIBS $LDAP_LIBS" + fi fi +AC_SUBST(LDAP_LIBS) + ######################################################## # Compile with MySQL support? AM_PATH_MYSQL([0.11.0],[default_modules="$default_modules pdb_mysql"],[]) -CFLAGS="$CFLAGS $MYSQL_CFLAGS" -LIBS="$LIBS $MYSQL_LIBS" ######################################################## # Compile with XML support? AM_PATH_XML2([2.0.0],[default_modules="$default_modules pdb_xml"],[]) -CFLAGS="$CFLAGS $XML_CFLAGS" -LIBS="$LIBS $XML_LIBS" ################################################# # check for automount support @@ -3349,9 +3351,12 @@ AC_ARG_WITH(shared-modules, done fi ]) -SMB_MODULE(pdb_xml, modules/xml.o, bin/xml.so, PDB) -SMB_MODULE(pdb_mysql, modules/mysql.o, bin/mysql.so, PDB) -SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o, bin/ldapsam.so, PDB) +SMB_MODULE(pdb_xml, modules/xml.o, bin/xml.so, PDB, + [ CFLAGS="$CFLAGS $XML_CFLAGS"; LIBS="$LIBS $XML_LIBS" ] ) +SMB_MODULE(pdb_mysql, modules/mysql.o, bin/mysql.so, PDB, + [ CFLAGS="$CFLAGS $MYSQL_CFLAGS"; LIBS="$LIBS $MYSQL_LIBS" ] ) +SMB_MODULE(pdb_ldap, passdb/pdb_ldap.o, bin/ldapsam.so, PDB, + [ LIBS="$LIBS $LDAP_LIBS" ] ) SMB_MODULE(pdb_smbpasswd, passdb/pdb_smbpasswd.o, bin/smbpasswd.so, PDB) SMB_MODULE(pdb_tdbsam, passdb/pdb_tdb.o, bin/tdbsam.so, PDB) SMB_MODULE(pdb_nisplussam, passdb/pdb_nisplus.o, bin/nisplussam.so, PDB) @@ -3390,6 +3395,8 @@ SMB_SUBSYSTEM(VFS) AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) +AC_SUBST(MODULES_CLEAN) + ################################################# # do extra things if we are running insure -- cgit From 99038b9aee31348c615a6fea3503c97f037c1c7e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 22:57:29 +0000 Subject: Do $(MAKE) modules_clean when compiling dynconfig.o. It's not the most elegant solution, but it works. (This used to be commit 02d202034dad56365a15c4e9fdcb7c420a77e1ed) --- source3/Makefile.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 7117281900..97f89ab686 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -672,11 +672,13 @@ MAKEDIR = || exec false; \ # but since we also require "make install prefix=/opt/samba" *not* to # rebuild it's a bit hard. -dynconfig.o: dynconfig.c Makefile modules_clean +dynconfig.o: dynconfig.c Makefile + @$(MAKE) modules_clean @echo Compiling $*.c @$(CC) $(FLAGS) $(PATH_FLAGS) -c $< -o $@ -dynconfig.po: dynconfig.c Makefile modules_clean +dynconfig.po: dynconfig.c Makefile + @$(MAKE) modules_clean @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi @echo Compiling $*.c with @PICFLAG@ -- cgit From 6d73e56b30047d3b8443e90df8359abb30a561d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 23:26:39 +0000 Subject: Give PARAMS_OBJ more priority (This used to be commit cf73797d110d271fc7a30c11e023c4d1ba2b5c9b) --- source3/Makefile.in | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 97f89ab686..a4109e5da7 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -181,7 +181,7 @@ POPT_LIB_OBJ = lib/popt_common.o UBIQX_OBJ = ubiqx/ubi_BinTree.o ubiqx/ubi_Cache.o ubiqx/ubi_SplayTree.o \ ubiqx/ubi_dLinkList.o ubiqx/ubi_sLinkList.o -PARAM_OBJ = param/loadparm.o param/params.o dynconfig.o +PARAM_OBJ = dynconfig.o param/loadparm.o param/params.o KRBCLIENT_OBJ = libads/kerberos.o @@ -280,7 +280,7 @@ SAM_STATIC_MODULES = sam/sam_plugin.o sam/sam_skel.o sam/sam_ads.o SAM_OBJ = sam/account.o sam/get_set_account.o sam/get_set_group.o \ sam/get_set_domain.o sam/interface.o $(SAM_STATIC_MODULES) -SAMTEST_OBJ = torture/samtest.o torture/cmd_sam.o $(SAM_OBJ) $(LIB_OBJ) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(READLINE_OBJ) lib/util_seaccess.o $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(PASSDB_OBJ) $(SECRETS_OBJ) $(GROUPDB_OBJ) +SAMTEST_OBJ = torture/samtest.o torture/cmd_sam.o $(PARAM_OBJ) $(SAM_OBJ) $(LIB_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(READLINE_OBJ) lib/util_seaccess.o $(LIBADS_OBJ) $(KRBCLIENT_OBJ) $(PASSDB_OBJ) $(SECRETS_OBJ) $(GROUPDB_OBJ) GROUPDB_OBJ = groupdb/mapping.o @@ -373,8 +373,8 @@ WREPL_OBJ = $(WREPL_OBJ1) $(PARAM_OBJ) $(UBIQX_OBJ) \ SWAT_OBJ1 = web/cgi.o web/diagnose.o web/startstop.o web/statuspage.o \ web/swat.o web/neg_lang.o -SWAT_OBJ = $(SWAT_OBJ1) $(PRINTING_OBJ) $(LIBSMB_OBJ) $(LOCKING_OBJ) \ - $(PARAM_OBJ) $(PASSDB_OBJ) $(SECRETS_OBJ) $(KRBCLIENT_OBJ) \ +SWAT_OBJ = $(SWAT_OBJ1) $(PARAM_OBJ) $(PRINTING_OBJ) $(LIBSMB_OBJ) \ + $(LOCKING_OBJ) $(PASSDB_OBJ) $(SECRETS_OBJ) $(KRBCLIENT_OBJ) \ $(UBIQX_OBJ) $(LIB_OBJ) $(GROUPDB_OBJ) $(PLAINTEXT_AUTH_OBJ) \ $(POPT_LIB_OBJ) @@ -436,8 +436,8 @@ SMBWRAPPER_OBJ1 = smbwrapper/wrapped.o SMBWRAPPER_OBJ = $(SMBW_OBJ) $(SMBWRAPPER_OBJ1) LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \ - libsmb/libsmb_cache.o $(LIB_OBJ) \ - $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ) + libsmb/libsmb_cache.o $(PARAM_OBJ) $(LIB_OBJ) \ + $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(UBIQX_OBJ) # This shared library is intended for linking with unit test programs # to test Samba internals. It's called libbigballofmud.so to @@ -445,7 +445,7 @@ LIBSMBCLIENT_OBJ = libsmb/libsmbclient.o libsmb/libsmb_compat.o \ LIBBIGBALLOFMUD_MAJOR = 0 -LIBBIGBALLOFMUD_OBJ = $(LIB_OBJ) $(UBIQX_OBJ) $(PARAM_OBJ) $(SECRETS_OBJ) \ +LIBBIGBALLOFMUD_OBJ = $(PARAM_OBJ) $(LIB_OBJ) $(UBIQX_OBJ) $(SECRETS_OBJ) \ $(LIBSMB_OBJ) $(LIBMSRPC_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_OBJ) \ $(GROUPDB_OBJ) $(KRBCLIENT_OBJ) @@ -462,9 +462,9 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_ads_cldap.o utils/net_help.o \ utils/net_rpc_join.o utils/net_time.o utils/net_lookup.o \ utils/net_cache.o -NET_OBJ = $(NET_OBJ1) $(SECRETS_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ +NET_OBJ = $(NET_OBJ1) $(PARAM_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \ - $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \ + $(KRBCLIENT_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \ $(LIBMSRPC_OBJ) $(LIBMSRPC_SERVER_OBJ) \ $(LIBADS_OBJ) $(LIBADS_SERVER_OBJ) $(POPT_LIB_OBJ) @@ -484,19 +484,19 @@ NMBLOOKUP_OBJ = utils/nmblookup.o $(PARAM_OBJ) $(UBIQX_OBJ) $(LIBNMB_OBJ) \ SMBTORTURE_OBJ1 = torture/torture.o torture/nbio.o torture/scanner.o torture/utable.o \ torture/denytest.o torture/mangle_test.o -SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) \ - $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) +SMBTORTURE_OBJ = $(SMBTORTURE_OBJ1) $(PARAM_OBJ) \ + $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) -MASKTEST_OBJ = torture/masktest.o $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(PARAM_OBJ) \ +MASKTEST_OBJ = torture/masktest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(UBIQX_OBJ) $(LIB_OBJ) -MSGTEST_OBJ = torture/msgtest.o $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(PARAM_OBJ) \ +MSGTEST_OBJ = torture/msgtest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(UBIQX_OBJ) $(LIB_OBJ) -LOCKTEST_OBJ = torture/locktest.o $(LOCKING_OBJ) $(KRBCLIENT_OBJ) $(LIBSMB_OBJ) $(PARAM_OBJ) \ - $(UBIQX_OBJ) $(LIB_OBJ) +LOCKTEST_OBJ = torture/locktest.o $(PARAM_OBJ) $(LOCKING_OBJ) $(KRBCLIENT_OBJ) \ + $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) -NSSTEST_OBJ = torture/nsstest.o $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) $(PARAM_OBJ) \ +NSSTEST_OBJ = torture/nsstest.o $(PARAM_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ $(UBIQX_OBJ) $(LIB_OBJ) VFSTEST_OBJ = torture/cmd_vfs.o torture/vfstest.o $(SMBD_OBJ_BASE) $(READLINE_OBJ) @@ -507,16 +507,15 @@ VFS_RECYCLE_OBJ = modules/vfs_recycle.o VFS_NETATALK_OBJ = modules/vfs_netatalk.o VFS_FAKE_PERMS_OBJ = modules/vfs_fake_perms.o -LOCKTEST2_OBJ = torture/locktest2.o $(LOCKING_OBJ) $(LIBSMB_OBJ) \ - $(KRBCLIENT_OBJ) $(PARAM_OBJ) \ - $(UBIQX_OBJ) $(LIB_OBJ) +LOCKTEST2_OBJ = torture/locktest2.o $(PARAM_OBJ) $(LOCKING_OBJ) $(LIBSMB_OBJ) \ + $(KRBCLIENT_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) -SMBCACLS_OBJ = utils/smbcacls.o $(LOCKING_OBJ) $(LIBSMB_OBJ) $(KRBCLIENT_OBJ) \ - $(PARAM_OBJ) \ - $(UBIQX_OBJ) $(LIB_OBJ) $(RPC_PARSE_OBJ) $(PASSDB_GET_SET_OBJ) \ - $(LIBMSRPC_OBJ) $(SECRETS_OBJ) $(POPT_LIB_OBJ) +SMBCACLS_OBJ = utils/smbcacls.o $(PARAM_OBJ) $(LOCKING_OBJ) $(LIBSMB_OBJ) \ + $(KRBCLIENT_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) $(RPC_PARSE_OBJ) \ + $(PASSDB_GET_SET_OBJ) $(LIBMSRPC_OBJ) $(SECRETS_OBJ) \ + $(POPT_LIB_OBJ) -TALLOCTORT_OBJ = lib/talloctort.o $(LIB_OBJ) $(PARAM_OBJ) $(UBIQX_OBJ) +TALLOCTORT_OBJ = lib/talloctort.o $(PARAM_OBJ) $(LIB_OBJ) $(UBIQX_OBJ) RPCTORTURE_OBJ = torture/rpctorture.o \ rpcclient/display.o \ @@ -530,7 +529,7 @@ RPCTORTURE_OBJ = torture/rpctorture.o \ DEBUG2HTML_OBJ = utils/debug2html.o ubiqx/debugparse.o -SMBFILTER_OBJ = utils/smbfilter.o $(LIBSMB_OBJ) $(PARAM_OBJ) \ +SMBFILTER_OBJ = utils/smbfilter.o $(PARAM_OBJ) $(LIBSMB_OBJ) \ $(UBIQX_OBJ) $(LIB_OBJ) $(KRBCLIENT_OBJ) PROTO_OBJ = $(SMBD_OBJ_MAIN) \ @@ -1121,8 +1120,8 @@ installclientlib: # Python extensions -PYTHON_OBJS = $(LIB_OBJ) $(LIBSMB_OBJ) $(RPC_PARSE_OBJ) $(UBIQX_OBJ) \ - $(PARAM_OBJ) $(LIBMSRPC_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \ +PYTHON_OBJS = $(PARAM_OBJ) $(LIB_OBJ) $(LIBSMB_OBJ) $(RPC_PARSE_OBJ) \ + $(UBIQX_OBJ) $(LIBMSRPC_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \ $(SECRETS_OBJ) $(KRBCLIENT_OBJ) python_ext: $(PYTHON_OBJS) -- cgit From dee03e1d2ddab1da588f3a2a0c911466ef21c0a1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Mar 2003 23:53:34 +0000 Subject: Don't do $(MAKE) modules_clean twice in a row - it breaks the build... (This used to be commit 1e1544ecc12d1e7c00080894786f500cd774a6b3) --- source3/Makefile.in | 1 - 1 file changed, 1 deletion(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index a4109e5da7..53f4fad9d2 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -677,7 +677,6 @@ dynconfig.o: dynconfig.c Makefile @$(CC) $(FLAGS) $(PATH_FLAGS) -c $< -o $@ dynconfig.po: dynconfig.c Makefile - @$(MAKE) modules_clean @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi @echo Compiling $*.c with @PICFLAG@ -- cgit From 0eff00c69225d106b827efed73e21d3538e72e0e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 26 Mar 2003 12:53:28 +0000 Subject: Output backtrace to logfile in smb_panic(), as suggested by mbp (only on systems that support it, of course) (This used to be commit bf439d733df6a11a25ff561a853c3382a3b34b96) --- source3/configure.in | 2 +- source3/include/local.h | 4 ++++ source3/lib/util.c | 35 +++++++++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 733037b977..cc67efbb90 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -796,7 +796,7 @@ AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf) AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink) AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm) # setbuffer, shmget, shm_open are needed for smbtorture -AC_CHECK_FUNCS(setbuffer shmget shm_open) +AC_CHECK_FUNCS(setbuffer shmget shm_open backtrace_symbols) # syscall() is needed for smbwrapper. AC_CHECK_FUNCS(syscall) diff --git a/source3/include/local.h b/source3/include/local.h index 29b0641119..4c3c58e14f 100644 --- a/source3/include/local.h +++ b/source3/include/local.h @@ -223,4 +223,8 @@ /* Max number of simultaneous winbindd socket connections. */ #define WINBINDD_MAX_SIMULTANEOUS_CLIENTS 200 + +/* Buffer size to use when printing backtraces */ +#define BACKTRACE_STACK_SIZE 64 + #endif diff --git a/source3/lib/util.c b/source3/lib/util.c index b67896c648..8bc36a4fb4 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1400,20 +1400,24 @@ void smb_panic(const char *why) { char *cmd; int result; + size_t i; + void *backtrace_stack[BACKTRACE_STACK_SIZE]; + size_t backtrace_size; + char **backtrace_strings; #ifdef DEVELOPER { extern char *global_clobber_region_function; extern unsigned int global_clobber_region_line; - + if (global_clobber_region_function) { DEBUG(0,("smb_panic: clobber_region() last called from [%s(%u)]\n", - global_clobber_region_function, - global_clobber_region_line)); + global_clobber_region_function, + global_clobber_region_line)); } } #endif - + cmd = lp_panic_action(); if (cmd && *cmd) { DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmd)); @@ -1421,19 +1425,34 @@ void smb_panic(const char *why) if (result == -1) DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n", - strerror(errno))); + strerror(errno))); else DEBUG(0, ("smb_panic(): action returned status %d\n", - WEXITSTATUS(result))); + WEXITSTATUS(result))); } DEBUG(0,("PANIC: %s\n", why)); + DEBUG(0, ("%d stack frames:\n", backtrace_size)); + +#ifdef HAVE_BACKTRACE_SYMBOLS + /* get the backtrace (stack frames) */ + backtrace_size = backtrace(backtrace_stack,BACKTRACE_STACK_SIZE); + backtrace_strings = backtrace_symbols(backtrace_stack, backtrace_size); + + if (backtrace_strings) { + for (i = 0; i < backtrace_size; i++) + DEBUG(0, (" #%u %s\n", i, backtrace_strings[i])); + } + + free(backtrace_strings); +#endif + dbgflush(); abort(); } /******************************************************************* - A readdir wrapper which just returns the file name. -********************************************************************/ + A readdir wrapper which just returns the file name. + ********************************************************************/ const char *readdirname(DIR *p) { -- cgit From 5edbbc1808537781790c0641ef7071f98aa81d1c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 26 Mar 2003 13:30:26 +0000 Subject: Fix $LDAP_LIBS (This used to be commit af98285f4e4fc4a0e890fed2c71b09280252b3f4) --- source3/configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index cc67efbb90..16f2330e3d 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2241,12 +2241,12 @@ if test x"$with_ldap_support" = x"yes"; then ################################################################## # we might need the lber lib on some systems. To avoid link errors # this test must be before the libldap test - AC_CHECK_LIB(lber, ber_scanf, [LDAP_LIBS="$LIBS -llber"]) + AC_CHECK_LIB(lber, ber_scanf, [LDAP_LIBS="$LDAP_LIBS -llber"]) ######################################################## # now see if we can find the ldap libs in standard paths if test x$have_ldap != xyes; then - AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LDAP_LIBS="$LIBS -lldap"; + AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LDAP_LIBS="$LDAP_LIBS -lldap"; AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])]) AC_CHECK_HEADERS([ldap.h lber.h], [default_modules="$default_modules pdb_ldap"]) -- cgit From 70cf597a790b6f667800e43f81b105f674e61a20 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 26 Mar 2003 13:43:29 +0000 Subject: Use execinfo.h to get prototypes for backtrace_symbols (fixes some warnings) (This used to be commit d453b656e56a9b836b76f1cdce8de65d7bc4eb6c) --- source3/configure.in | 2 +- source3/include/includes.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 16f2330e3d..445461e4f7 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -473,7 +473,7 @@ AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h termio.h) AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h) AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h dlfcn.h) -AC_CHECK_HEADERS(sys/syslog.h syslog.h) +AC_CHECK_HEADERS(sys/syslog.h syslog.h execinfo.h) # In valgrind 1.0.x, it's just valgrind.h. In 1.9.x+ there's a # subdirectory of headers. diff --git a/source3/include/includes.h b/source3/include/includes.h index 2bba9d5084..f536ea88fe 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -345,6 +345,10 @@ #include #endif +#ifdef HAVE_EXECINFO_H +#include +#endif + #ifdef HAVE_SYS_CAPABILITY_H #if defined(BROKEN_REDHAT_7_SYSTEM_HEADERS) && !defined(_I386_STATFS_H) -- cgit From fa0ea6d5619f52dd63a469a2828d984dc439b16f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 26 Mar 2003 13:49:23 +0000 Subject: Use SAFE_FREE() instead of plain free() - pointed out by metze (This used to be commit b49436d020f8d88d42428c83ea9a278d3433d134) --- source3/lib/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/lib/util.c b/source3/lib/util.c index 8bc36a4fb4..da98f5a3cf 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1441,9 +1441,10 @@ void smb_panic(const char *why) if (backtrace_strings) { for (i = 0; i < backtrace_size; i++) DEBUG(0, (" #%u %s\n", i, backtrace_strings[i])); + + SAFE_FREE(backtrace_strings); } - free(backtrace_strings); #endif dbgflush(); -- cgit From 4d7388641a087161fb50df5614f437960c8f799c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Mar 2003 19:31:44 +0000 Subject: Fix extra NULL arg added during app-head merge. Jeremy. (This used to be commit 4868633bc8182b939190d3cdb86b24cbdb78b5e1) --- source3/printing/printing.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3') diff --git a/source3/printing/printing.c b/source3/printing/printing.c index da29eab9f2..b6c4969761 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -838,7 +838,7 @@ static void store_queue_struct(struct tdb_print_db *pdb, struct traverse_struct data.dsize += tdb_pack(NULL, 0, NULL, "d", qcount); for (i = 0; i < pts->qcount; i++) { - data.dsize += tdb_pack(NULL, 0, NULL, "ddddddff", + data.dsize += tdb_pack(NULL, 0, "ddddddff", (uint32)queue[i].job, (uint32)queue[i].size, (uint32)queue[i].page_count, @@ -853,9 +853,9 @@ static void store_queue_struct(struct tdb_print_db *pdb, struct traverse_struct return; len = 0; - len += tdb_pack(data.dptr + len, data.dsize - len, NULL, "d", qcount); + len += tdb_pack(data.dptr + len, data.dsize - len, "d", qcount); for (i = 0; i < pts->qcount; i++) { - len += tdb_pack(data.dptr + len, data.dsize - len, NULL, "ddddddff", + len += tdb_pack(data.dptr + len, data.dsize - len, "ddddddff", (uint32)queue[i].job, (uint32)queue[i].size, (uint32)queue[i].page_count, -- cgit From 43c5f197ef7da7ede60091986ad5e2f38a2a8587 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Mar 2003 19:42:51 +0000 Subject: Add defines for platforms that need them. Jeremy. (This used to be commit f81128bc0187765f6f9e6d7e05eaebf778cbfec8) --- source3/configure.in | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 445461e4f7..999bd3c5f5 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -938,6 +938,7 @@ if test "$enable_shared" = "yes"; then PICSUFFIX="po.o" fi AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block]) + AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly]) ;; *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4]) BLDSHARED="true" @@ -945,6 +946,7 @@ if test "$enable_shared" = "yes"; then SONAMEFLAG="-Wl,-h," PICFLAG="-KPIC" # Is this correct for SunOS AC_DEFINE(STAT_ST_BLOCKSIZE,512) + AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly]) ;; *netbsd* | *freebsd*) BLDSHARED="true" LDSHFLAGS="-shared" @@ -952,6 +954,7 @@ if test "$enable_shared" = "yes"; then SONAMEFLAG="-Wl,-soname," PICFLAG="-fPIC -DPIC" AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block]) + AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly]) ;; *openbsd*) BLDSHARED="true" LDSHFLAGS="-shared" @@ -959,6 +962,7 @@ if test "$enable_shared" = "yes"; then SONAMEFLAG="-Wl,-soname," PICFLAG="-fPIC" AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block]) + AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly]) ;; *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix]) case "$host_os" in @@ -1001,6 +1005,7 @@ if test "$enable_shared" = "yes"; then fi DYNEXP="-Wl,-E" AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block]) + AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element]) ;; *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx]) AC_DEFINE(STAT_ST_BLOCKSIZE,512) @@ -1011,6 +1016,7 @@ if test "$enable_shared" = "yes"; then SONAMEFLAG="-Wl,-soname," PICFLAG="-fPIC" AC_DEFINE(STAT_ST_BLOCKSIZE,512) + AC_DEFINE(BROKEN_GETGRNAM,1,[Does getgrnam work correctly]) ;; *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix]) AC_DEFINE(STAT_ST_BLOCKSIZE,512) -- cgit From 4c74bfcbda44f868bcfd2f5edae0868bab890626 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 26 Mar 2003 20:16:48 +0000 Subject: Remove LDAP_LIBS and just use LIBS again as before. I'll fix this better later. (This used to be commit c6807d20457325012c4c9edd137b2f1f67e98ec4) --- source3/Makefile.in | 2 +- source3/configure.in | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 53f4fad9d2..4e02eb8317 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -987,7 +987,7 @@ bin/mysql.@SHLIBEXT@: $(MYSQL_OBJ) bin/ldapsam.@SHLIBEXT@: passdb/pdb_ldap.o @echo "Building plugin $@" - @$(SHLD) $(LDSHFLAGS) -o $@ @LDAP_LIBS@ passdb/pdb_ldap.o \ + @$(SHLD) $(LDSHFLAGS) -o $@ passdb/pdb_ldap.o \ @SONAMEFLAG@`basename $@` bin/tdbsam.@SHLIBEXT@: passdb/pdb_tdb.o diff --git a/source3/configure.in b/source3/configure.in index 999bd3c5f5..82e4b9a50d 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2247,12 +2247,12 @@ if test x"$with_ldap_support" = x"yes"; then ################################################################## # we might need the lber lib on some systems. To avoid link errors # this test must be before the libldap test - AC_CHECK_LIB(lber, ber_scanf, [LDAP_LIBS="$LDAP_LIBS -llber"]) + AC_CHECK_LIB(lber, ber_scanf, [LIBS="$LIBS -llber"]) ######################################################## # now see if we can find the ldap libs in standard paths if test x$have_ldap != xyes; then - AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LDAP_LIBS="$LDAP_LIBS -lldap"; + AC_CHECK_LIB(ldap, ldap_domain2hostlist, [LIBS="$LIBS -lldap"; AC_DEFINE(HAVE_LDAP,1,[Whether ldap is available])]) AC_CHECK_HEADERS([ldap.h lber.h], [default_modules="$default_modules pdb_ldap"]) @@ -2267,13 +2267,8 @@ if test x"$with_ldap_support" = x"yes"; then AC_DEFINE_UNQUOTED(LDAP_SET_REBIND_PROC_ARGS, $pam_ldap_cv_ldap_set_rebind_proc, [Number of arguments to ldap_set_rebind_proc]) fi - if test x"$with_ads_support" = x"yes"; then - LIBS="$LIBS $LDAP_LIBS" - fi fi -AC_SUBST(LDAP_LIBS) - ######################################################## # Compile with MySQL support? AM_PATH_MYSQL([0.11.0],[default_modules="$default_modules pdb_mysql"],[]) -- cgit From 1556b9b53c69c2a5b2ac2bdfea46df7725094cf8 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 26 Mar 2003 22:15:37 +0000 Subject: Fix DOS del command with widelinks = False. Jeremy. (This used to be commit ae754e9355c78c22ff5ca5a7f3276e61b4a8fcb7) --- source3/smbd/reply.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 1a1c84efed..bf74d997b8 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -401,7 +401,8 @@ int reply_chkpth(connection_struct *conn, char *inbuf,char *outbuf, int dum_size if (check_name(name,conn)) { if (VALID_STAT(sbuf) || vfs_stat(conn,name,&sbuf) == 0) - ok = S_ISDIR(sbuf.st_mode); + if (!(ok = S_ISDIR(sbuf.st_mode))) + errno = ENOTDIR; } if (!ok) { -- cgit From e6df31f14b3fa0a8819b8dfe443eaea009ac9657 Mon Sep 17 00:00:00 2001 From: "Christopher R. Hertel" Date: Thu, 27 Mar 2003 05:11:25 +0000 Subject: The definition of pstrcpy_base(), and the preceeding comments, were given twice (probably a cut/paste error). The definition of pstrcpy_base(), and the preceeding comments, were given twice (probably a cut/paste error). (This used to be commit 5306f6f7c88234d51c4ff13d5451d3489de6b00e) --- source3/include/safe_string.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'source3') diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h index f26a5785cb..a6b352b02e 100644 --- a/source3/include/safe_string.h +++ b/source3/include/safe_string.h @@ -122,21 +122,15 @@ size_t __unsafe_string_function_usage_here_char__(void); #define safe_strcpy_base(dest, src, base, size) \ safe_strcpy(dest, src, size-PTR_DIFF(dest,base)-1) -/* String copy functions - macro hell below adds 'type checking' (limited, but the best we can - do in C) and may tag with function name/number to record the last 'clobber region' on - that string */ +/* String copy functions - macro hell below adds 'type checking' + (limited, but the best we can do in C) and may tag with function + name/number to record the last 'clobber region' on that string */ #define pstrcpy(d,s) safe_strcpy((d), (s),sizeof(pstring)-1) #define pstrcat(d,s) safe_strcat((d), (s),sizeof(pstring)-1) #define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1) #define fstrcat(d,s) safe_strcat((d),(s),sizeof(fstring)-1) -/* the addition of the DEVELOPER checks in safe_strcpy means we must - * update a lot of code. To make this a little easier here are some - * functions that provide the lengths with less pain */ -#define pstrcpy_base(dest, src, pstring_base) \ - safe_strcpy(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1) - /* Inside the _fn variants of these is a call to clobber_region(), - * which might destroy the stack on a buggy function. We help the -- cgit From 11db21cc1c00d63c6b23ec6b3a3bdb48728b2b64 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 27 Mar 2003 12:08:46 +0000 Subject: Use the new modules system in VFS. If a module can't be loaded with the new modules system, we still fall back to the old system. (This used to be commit cebe8d8b424f10006f2f791a8f086c6c8a7f5d57) --- source3/Makefile.in | 24 +++---- source3/configure.in | 7 ++ source3/include/vfs.h | 4 +- source3/modules/vfs_audit.c | 14 ++-- source3/modules/vfs_extd_audit.c | 15 ++-- source3/modules/vfs_fake_perms.c | 8 +-- source3/modules/vfs_netatalk.c | 8 +-- source3/modules/vfs_recycle.c | 41 ++--------- source3/smbd/server.c | 2 +- source3/smbd/vfs.c | 143 ++++++++++++++++++++++++++++++--------- 10 files changed, 155 insertions(+), 111 deletions(-) (limited to 'source3') diff --git a/source3/Makefile.in b/source3/Makefile.in index 4e02eb8317..32c8e73b51 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -136,8 +136,7 @@ SCRIPTS = $(srcdir)/script/smbtar $(srcdir)/script/addtosmbpass $(srcdir)/script QUOTAOBJS=@QUOTAOBJS@ -VFS_MODULES = bin/vfs_audit.@SHLIBEXT@ bin/vfs_extd_audit.@SHLIBEXT@ bin/vfs_recycle.@SHLIBEXT@ \ - bin/vfs_netatalk.@SHLIBEXT@ bin/vfs_fake_perms.@SHLIBEXT@ +VFS_MODULES = @VFS_MODULES@ PDB_MODULES = @PDB_MODULES@ RPC_MODULES = @RPC_MODULES@ CHARSET_MODULES = @CHARSET_MODULES@ @@ -327,8 +326,8 @@ SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \ smbd/change_trust_pw.o \ $(MANGLE_OBJ) -SMBD_OBJ_BASE = $(SMBD_OBJ_SRV) $(MSDFS_OBJ) $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) \ - $(RPC_SERVER_OBJ) $(RPC_PARSE_OBJ) $(SECRETS_OBJ) \ +SMBD_OBJ_BASE = $(PARAM_OBJ) $(SMBD_OBJ_SRV) $(MSDFS_OBJ) $(LIBSMB_OBJ) \ + $(RPC_SERVER_OBJ) $(RPC_PARSE_OBJ) $(SECRETS_OBJ) $(UBIQX_OBJ) \ $(LOCKING_OBJ) $(PASSDB_OBJ) $(PRINTING_OBJ) $(PROFILE_OBJ) \ $(LIB_OBJ) $(PRINTBACKEND_OBJ) $(QUOTAOBJS) $(OPLOCK_OBJ) \ $(NOTIFY_OBJ) $(GROUPDB_OBJ) $(AUTH_OBJ) \ @@ -346,8 +345,7 @@ PRINTBACKEND_OBJ = printing/printing.o printing/nt_printing.o printing/notify.o MSDFS_OBJ = msdfs/msdfs.o -SMBD_OBJ = $(SMBD_OBJ_MAIN) $(SMBD_OBJ_BASE) - +SMBD_OBJ = $(SMBD_OBJ_BASE) $(SMBD_OBJ_MAIN) NMBD_OBJ1 = nmbd/asyncdns.o nmbd/nmbd.o nmbd/nmbd_become_dmb.o \ nmbd/nmbd_become_lmb.o nmbd/nmbd_browserdb.o \ nmbd/nmbd_browsesync.o nmbd/nmbd_elections.o \ @@ -603,7 +601,7 @@ NTLM_AUTH_OBJ = utils/ntlm_auth.o $(LIBNTLMSSP_OBJ) $(LIBSAMBA_OBJ) $(POPT_LIB_O # now the rules... ###################################################################### all : SHOWFLAGS proto_exists $(SBIN_PROGS) $(BIN_PROGS) $(SHLIBS) \ - $(TORTURE_PROGS) @EXTRA_ALL_TARGETS@ + $(TORTURE_PROGS) $(MODULES) @EXTRA_ALL_TARGETS@ pam_smbpass : SHOWFLAGS bin/pam_smbpass.@SHLIBEXT@ @@ -1020,27 +1018,27 @@ bin/xml.@SHLIBEXT@: $(XML_OBJ) @$(SHLD) $(LDSHFLAGS) -o $@ $(XML_OBJ) @XML_LIBS@ \ @SONAMEFLAG@`basename $@` -bin/vfs_audit.@SHLIBEXT@: $(VFS_AUDIT_OBJ) +bin/audit.@SHLIBEXT@: $(VFS_AUDIT_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_AUDIT_OBJ) \ @SONAMEFLAG@`basename $@` -bin/vfs_extd_audit.@SHLIBEXT@: $(VFS_EXTD_AUDIT_OBJ) +bin/extd_audit.@SHLIBEXT@: $(VFS_EXTD_AUDIT_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_AUDIT_OBJ) \ @SONAMEFLAG@`basename $@` -bin/vfs_recycle.@SHLIBEXT@: $(VFS_RECYCLE_OBJ) +bin/recycle.@SHLIBEXT@: $(VFS_RECYCLE_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_RECYCLE_OBJ) \ @SONAMEFLAG@`basename $@` -bin/vfs_netatalk.@SHLIBEXT@: $(VFS_NETATALK_OBJ) +bin/netatalk.@SHLIBEXT@: $(VFS_NETATALK_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_NETATALK_OBJ) \ @SONAMEFLAG@`basename $@` -bin/vfs_fake_perms.@SHLIBEXT@: $(VFS_FAKE_PERMS_OBJ) +bin/fake_perms.@SHLIBEXT@: $(VFS_FAKE_PERMS_OBJ) @echo "Building plugin $@" @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_FAKE_PERMS_OBJ) \ @SONAMEFLAG@`basename $@` @@ -1074,7 +1072,7 @@ bin/t_strcmp@EXEEXT@: bin/libbigballofmud.@SHLIBEXT@ torture/t_strcmp.o bin/t_stringoverflow@EXEEXT@: bin/libbigballofmud.@SHLIBEXT@ torture/t_stringoverflow.o $(CC) $(FLAGS) -o $@ torture/t_stringoverflow.o -L./bin -lbigballofmud -install: installbin installman installscripts installdat installswat +install: installbin installman installscripts installdat installswat installmodules # DESTDIR is used here to prevent packagers wasting their time # duplicating the Makefile. Remove it and you will have the privelege diff --git a/source3/configure.in b/source3/configure.in index 82e4b9a50d..a299864068 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3394,6 +3394,13 @@ SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), bin/fake_perms.so, VFS) SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK), bin/netatalk.so, VFS) SMB_SUBSYSTEM(VFS) +SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), bin/recycle.so, VFS) +SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), bin/audit.so, VFS) +SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), bin/extd_audit.so, VFS) +SMB_MODULE(vfs_fake_perms, \$(VFS_FAKE_PERMS_OBJ), bin/fake_perms.so, VFS) +SMB_MODULE(vfs_netatalk, \$(VFS_NETATALK), bin/netatalk.so, VFS) +SMB_SUBSYSTEM(VFS) + AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) AC_SUBST(MODULES_CLEAN) diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 9a06764371..756e417814 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -48,7 +48,7 @@ #define SMB_VFS_INTERFACE_VERSION 5 -/* Version of supported cascaded interface backward copmatibility. +/* Version of supported cascaded interface backward compatibility. (version 5 corresponds to SMB_VFS_INTERFACE_VERSION 5) It is used in vfs_init_custom() to detect VFS modules which conform to cascaded VFS interface but implement elder version than current version of Samba uses. @@ -77,7 +77,7 @@ is unloaded from smbd process using sys_dlclose(). Prototypes: - vfs_op_tuple *vfs_init(int *vfs_version, const struct vfs_ops *def_vfs_ops, + vfs_op_tuple *vfs_init(const struct vfs_ops *def_vfs_ops, struct smb_vfs_handle_struct *vfs_handle); void vfs_done(connection_struct *conn); diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c index 1944c98e53..fa9bf67a67 100644 --- a/source3/modules/vfs_audit.c +++ b/source3/modules/vfs_audit.c @@ -98,10 +98,9 @@ static vfs_op_tuple audit_ops[] = { /* VFS initialisation function. Return vfs_op_tuple array back to SAMBA. */ -vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, +static vfs_op_tuple *audit_init(const struct vfs_ops *def_vfs_ops, struct smb_vfs_handle_struct *vfs_handle) { - *vfs_version = SMB_VFS_INTERFACE_VERSION; memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops)); audit_handle = vfs_handle; @@ -111,12 +110,6 @@ vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, return audit_ops; } -/* VFS finalization function. */ -void vfs_done(connection_struct *conn) -{ - syslog(SYSLOG_PRIORITY, "VFS_DONE: vfs module unloaded\n"); -} - /* Implementation of vfs_ops. Pass everything on to the default operation but log event first. */ @@ -276,3 +269,8 @@ static int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode) return result; } + +int vfs_audit_init(void) +{ + return smb_register_vfs("audit", audit_init, SMB_VFS_INTERFACE_VERSION); +} diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c index c75dc1d09c..f60acab36a 100644 --- a/source3/modules/vfs_extd_audit.c +++ b/source3/modules/vfs_extd_audit.c @@ -99,10 +99,9 @@ static vfs_op_tuple audit_ops[] = { /* VFS initialisation function. Return vfs_op_tuple array back to SAMBA. */ -vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, +static vfs_op_tuple *audit_init(const struct vfs_ops *def_vfs_ops, struct smb_vfs_handle_struct *vfs_handle) { - *vfs_version = SMB_VFS_INTERFACE_VERSION; memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops)); audit_handle = vfs_handle; @@ -113,13 +112,6 @@ vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, return audit_ops; } -/* VFS finalization function. */ - -void vfs_done(connection_struct *conn) -{ - syslog(SYSLOG_PRIORITY, "VFS_DONE: vfs module unloaded\n"); -} - /* Implementation of vfs_ops. Pass everything on to the default operation but log event first. */ @@ -317,3 +309,8 @@ static int audit_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode) return result; } + +int vfs_extd_audit_init(void) +{ + return smb_register_vfs("extd_audit", audit_init, SMB_VFS_INTERFACE_VERSION); +} diff --git a/source3/modules/vfs_fake_perms.c b/source3/modules/vfs_fake_perms.c index 85515df21a..121a99a451 100644 --- a/source3/modules/vfs_fake_perms.c +++ b/source3/modules/vfs_fake_perms.c @@ -267,12 +267,11 @@ static vfs_op_tuple fake_perms_ops[] = { /* VFS initialisation - return initialized vfs_op_tuple array back to Samba */ -vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, +static vfs_op_tuple *fake_perms_init(const struct vfs_ops *def_vfs_ops, struct smb_vfs_handle_struct *vfs_handle) { DEBUG(3, ("Initialising default vfs hooks\n")); - *vfs_version = SMB_VFS_INTERFACE_VERSION; memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops)); /* Remember vfs_handle for further allocation and referencing of private @@ -282,8 +281,7 @@ vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, return fake_perms_ops; } -/* VFS finalization function */ -void vfs_done(connection_struct *conn) +int vfs_fake_perms_init(void) { - DEBUG(3, ("Finalizing default vfs hooks\n")); + return smb_register_vfs("fake_perms", fake_perms_init, SMB_VFS_INTERFACE_VERSION); } diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c index b69a900e14..c9e3cde621 100644 --- a/source3/modules/vfs_netatalk.c +++ b/source3/modules/vfs_netatalk.c @@ -410,10 +410,9 @@ static vfs_op_tuple atalk_ops[] = { }; /* VFS initialisation function. Return vfs_op_tuple array back to SAMBA. */ -vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, +static vfs_op_tuple *netatalk_init(const struct vfs_ops *def_vfs_ops, struct smb_vfs_handle_struct *vfs_handle) { - *vfs_version = SMB_VFS_INTERFACE_VERSION; memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops)); atalk_handle = vfs_handle; @@ -422,8 +421,7 @@ vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, return atalk_ops; } -/* VFS finalization function. */ -void vfs_done(connection_struct *conn) +int vfs_netatalk_init(void) { - DEBUG(3, ("ATALK: vfs module unloaded\n")); + return smb_register_vfs("netatalk", netatalk_init, SMB_VFS_INTERFACE_VERSION); } diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index ba453bad2c..a669d864c6 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -87,13 +87,12 @@ static vfs_op_tuple recycle_ops[] = { * * @retval initialised vfs_op_tuple array **/ -vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, +static vfs_op_tuple *recycle_init(const struct vfs_ops *def_vfs_ops, struct smb_vfs_handle_struct *vfs_handle) { TALLOC_CTX *mem_ctx = NULL; DEBUG(10, ("Initializing VFS module recycle\n")); - *vfs_version = SMB_VFS_INTERFACE_VERSION; memcpy(&default_vfs_ops, def_vfs_ops, sizeof(struct vfs_ops)); vfs_recycle_debug_level = debug_add_class("vfs_recycle_bin"); if (vfs_recycle_debug_level == -1) { @@ -120,39 +119,6 @@ vfs_op_tuple *vfs_init(int *vfs_version, struct vfs_ops *def_vfs_ops, return recycle_ops; } -/** - * VFS finalization function. - * - **/ -void vfs_done(void) -{ - recycle_bin_private_data *recdata; - recycle_bin_connections *recconn; - - DEBUG(10, ("Unloading/Cleaning VFS module recycle bin\n")); - - if (recycle_bin_private_handle) - recdata = (recycle_bin_private_data *)(recycle_bin_private_handle->data); - else { - DEBUG(0, ("Recycle bin not initialized!\n")); - return; - } - - if (recdata) { - if (recdata->conns) { - recconn = recdata->conns; - while (recconn) { - talloc_destroy(recconn->data->mem_ctx); - recconn = recconn->next; - } - } - if (recdata->mem_ctx) { - talloc_destroy(recdata->mem_ctx); - } - recdata = NULL; - } -} - static int recycle_connect(struct connection_struct *conn, const char *service, const char *user) { TALLOC_CTX *ctx = NULL; @@ -646,3 +612,8 @@ done: SAFE_FREE(final_name); return rc; } + +int vfs_recycle_init(void) +{ + return smb_register_vfs("recycle", recycle_init, SMB_VFS_INTERFACE_VERSION); +} diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 715e916263..7848e71db2 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -3,7 +3,7 @@ Main SMB server routines Copyright (C) Andrew Tridgell 1992-1998 Copyright (C) Martin Pool 2002 - Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Jelmer Vernooij 2002-2003 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 diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 3bbe8a737a..cdff26ed1e 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -27,6 +27,13 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS +struct vfs_init_function_entry { + char *name; + vfs_op_tuple *ops, *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *); + struct vfs_init_function_entry *prev, *next; +}; + +static struct vfs_init_function_entry *backends = NULL; /* Some structures to help us initialise the vfs operations table */ @@ -127,6 +134,56 @@ static struct vfs_ops default_vfs_ops = { vfswrap_sys_acl_free_qualifier }; +/**************************************************************************** + maintain the list of available backends +****************************************************************************/ + +struct vfs_init_function_entry *vfs_find_backend_entry(const char *name) +{ + struct vfs_init_function_entry *entry = backends; + + while(entry) { + if (strequal(entry->name, name)) return entry; + entry = entry->next; + } + + return NULL; +} + +BOOL smb_register_vfs(const char *name, vfs_op_tuple *(*init)(const struct vfs_ops *, struct smb_vfs_handle_struct *), int version) +{ + struct vfs_init_function_entry *entry = backends; + + if ((version < SMB_VFS_INTERFACE_CASCADED)) { + DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", + version, SMB_VFS_INTERFACE_VERSION )); + return False; + } + + if ((version < SMB_VFS_INTERFACE_VERSION)) { + DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ + Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", + version, SMB_VFS_INTERFACE_VERSION, version )); + return False; + } + + while(entry) { + if (strequal(entry->name, name)) { + DEBUG(0,("VFS module %s already loaded!\n", name)); + return False; + } + entry = entry->next; + } + + entry = smb_xmalloc(sizeof(struct vfs_init_function_entry)); + entry->name = smb_xstrdup(name); + entry->init = init; + + DLIST_ADD(backends, entry); + DEBUG(5, ("Successfully added vfs backend '%s'\n", name)); + return True; +} + /**************************************************************************** initialise default vfs hooks ****************************************************************************/ @@ -148,48 +205,68 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object) int vfs_version = -1; vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *); int i; + struct vfs_init_function_entry *entry; DEBUG(3, ("Initialising custom vfs hooks from %s\n", vfs_object)); - /* Open object file */ + if(!backends) static_init_vfs; + + /* First, try to load the module with the new module system */ + if((entry = vfs_find_backend_entry(vfs_object)) || + (smb_probe_module("vfs", vfs_object) && + (entry = vfs_find_backend_entry(vfs_object)))) { + + DEBUG(0,("Successfully loaded %s with the new modules system\n", vfs_object)); + + if ((ops = entry->init(&conn->vfs_ops, conn->vfs_private)) == NULL) { + DEBUG(0, ("vfs init function from %s failed\n", vfs_object)); + sys_dlclose(conn->vfs_private->handle); + return False; + } + } else { + /* If that doesn't work, fall back to the old system + * (This part should go away after a while, it's only here + * for backwards compatibility) */ - if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) { - DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror())); - return False; - } + /* Open object file */ - /* Get handle on vfs_init() symbol */ + if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) { + DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror())); + return False; + } - init_fptr = (vfs_op_tuple *(*)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *))sys_dlsym(conn->vfs_private->handle, "vfs_init"); + /* Get handle on vfs_init() symbol */ - if (init_fptr == NULL) { - DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object)); - sys_dlclose(conn->vfs_private->handle); - return False; - } + init_fptr = (vfs_op_tuple *(*)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *))sys_dlsym(conn->vfs_private->handle, "vfs_init"); - /* Initialise vfs_ops structure */ + if (init_fptr == NULL) { + DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object)); + sys_dlclose(conn->vfs_private->handle); + return False; + } - if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) { - DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object)); - sys_dlclose(conn->vfs_private->handle); - return False; - } - - if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) { - DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", - vfs_version, SMB_VFS_INTERFACE_VERSION )); - sys_dlclose(conn->vfs_private->handle); - return False; - } - - if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) { - DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ -Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", - vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version )); - sys_dlclose(conn->vfs_private->handle); - return False; - } + /* Initialise vfs_ops structure */ + if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) { + DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object)); + sys_dlclose(conn->vfs_private->handle); + return False; + } + + if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) { + DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", + vfs_version, SMB_VFS_INTERFACE_VERSION )); + sys_dlclose(conn->vfs_private->handle); + return False; + } + + if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) { + DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ + Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", + vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version )); + sys_dlclose(conn->vfs_private->handle); + return False; + } + } for(i=0; ops[i].op != NULL; i++) { DEBUG(3, ("Checking operation #%d (type %d, layer %d)\n", i, ops[i].type, ops[i].layer)); -- cgit From 75d4193e6397e4a42343f09fb4de608605753d01 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 27 Mar 2003 12:54:50 +0000 Subject: local_gid_to_sid() could use pdb_ldap, which for now requires ROOT. (This used to be commit a51ce67e322f91a56acb9e358ee8b2254b2e7792) --- source3/smbd/uid.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3') diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 6ac3528b1a..b9cf0de3bd 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -781,7 +781,9 @@ DOM_SID *gid_to_sid(DOM_SID *psid, gid_t gid) } /* Make sure we report failure, (when psid == NULL) */ + become_root(); psid = local_gid_to_sid(psid, gid); + unbecome_root(); DEBUG(10,("gid_to_sid: local %u -> %s\n", (unsigned int)gid, sid_to_string(sid, psid))); if (psid) store_gid_sid_cache(psid, SID_NAME_DOM_GRP, gid); -- cgit From 7c6a4de6f97287e43405b66baa81aa328315de7c Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 27 Mar 2003 14:30:10 +0000 Subject: This is no functional change. It just makes pdb_ldap.c a bit easier to understand by moving the logic for init_ldap_from_sam and friends around. Volker (This used to be commit 124c80facba364033f72b20660f347390effba59) --- source3/passdb/pdb_ldap.c | 74 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 24 deletions(-) (limited to 'source3') diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index c54095b250..c8ae96344a 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -1292,13 +1292,15 @@ static BOOL need_ldap_mod(BOOL pdb_add, const SAM_ACCOUNT * sampass, enum pdb_el *********************************************************************/ static void make_ldap_mod(LDAP *ldap_struct, LDAPMessage *existing, LDAPMod ***mods, - const SAM_ACCOUNT *sampass, BOOL pdb_add, + const SAM_ACCOUNT *sampass, + BOOL (*need_update)(const SAM_ACCOUNT *, + enum pdb_elements), enum pdb_elements element, const char *attribute, const char *newval) { char **values = NULL; - if (!need_ldap_mod(pdb_add, sampass, element)) { + if (!need_update(sampass, element)) { return; } @@ -1348,7 +1350,8 @@ Initialize SAM_ACCOUNT from an LDAP query static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, LDAPMessage *existing, LDAPMod *** mods, const SAM_ACCOUNT * sampass, - BOOL pdb_add) + BOOL (*need_update)(const SAM_ACCOUNT *, + enum pdb_elements)) { pstring temp; uint32 rid; @@ -1364,7 +1367,7 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, * took out adding "objectclass: sambaAccount" * do this on a per-mod basis */ - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_USERNAME, "uid", pdb_get_username(sampass)); DEBUG(2, ("Setting entry for user: %s\n", pdb_get_username(sampass))); @@ -1392,7 +1395,7 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, } slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_USERSID, "rid", temp); @@ -1412,7 +1415,7 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, } slprintf(temp, sizeof(temp) - 1, "%i", rid); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_GROUPSID, "primaryGroupID", temp); /* displayName, cn, and gecos should all be the same @@ -1423,55 +1426,55 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, * it does not exist. */ - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_FULLNAME, "displayName", pdb_get_fullname(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_ACCTDESC, "description", pdb_get_acct_desc(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_WORKSTATIONS, "userWorkstations", pdb_get_workstations(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_SMBHOME, "smbHome", pdb_get_homedir(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_DRIVE, "homeDrive", pdb_get_dir_drive(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_LOGONSCRIPT, "scriptPath", pdb_get_logon_script(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_PROFILE, "profilePath", pdb_get_profile_path(sampass)); slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logon_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_LOGONTIME, "logonTime", temp); slprintf(temp, sizeof(temp) - 1, "%li", pdb_get_logoff_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_LOGOFFTIME, "logoffTime", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_kickoff_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_KICKOFFTIME, "kickoffTime", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_can_change_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_CANCHANGETIME, "pwdCanChange", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_must_change_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_MUSTCHANGETIME, "pwdMustChange", temp); if ((pdb_get_acct_ctrl(sampass)&(ACB_WSTRUST|ACB_SVRTRUST|ACB_DOMTRUST))|| @@ -1479,22 +1482,22 @@ static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state, pdb_sethexpwd (temp, pdb_get_lanman_passwd(sampass), pdb_get_acct_ctrl(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_LMPASSWD, "lmPassword", temp); pdb_sethexpwd (temp, pdb_get_nt_passwd(sampass), pdb_get_acct_ctrl(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_NTPASSWD, "ntPassword", temp); slprintf (temp, sizeof (temp) - 1, "%li", pdb_get_pass_last_set_time(sampass)); - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_PASSLASTSET, "pwdLastSet", temp); } /* FIXME: Hours stuff goes in LDAP */ - make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, pdb_add, + make_ldap_mod(ldap_state->ldap_struct, existing, mods, sampass, need_update, PDB_ACCTCTRL, "acctFlags", pdb_encode_acct_ctrl (pdb_get_acct_ctrl(sampass), NEW_PW_FORMAT_SPACE_PADDED_LEN)); @@ -1940,6 +1943,16 @@ static NTSTATUS ldapsam_delete_sam_account(struct pdb_methods *my_methods, SAM_A return ret; } +/********************************************************************** + Helper function to determine for update_sam_account whether + we need LDAP modification. +*********************************************************************/ +static BOOL element_is_changed(const SAM_ACCOUNT *sampass, + enum pdb_elements element) +{ + return IS_SAM_CHANGED(sampass, element); +} + /********************************************************************** Update SAM_ACCOUNT *********************************************************************/ @@ -1967,7 +1980,8 @@ static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_A entry = ldap_first_entry(ldap_state->ldap_struct, result); dn = ldap_get_dn(ldap_state->ldap_struct, entry); - if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd, False)) { + if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd, + element_is_changed)) { DEBUG(0, ("ldapsam_update_sam_account: init_ldap_from_sam failed!\n")); ldap_msgfree(result); return NT_STATUS_UNSUCCESSFUL; @@ -1996,6 +2010,17 @@ static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_A return NT_STATUS_OK; } +/********************************************************************** + Helper function to determine for update_sam_account whether + we need LDAP modification. +*********************************************************************/ +static BOOL element_is_set_or_changed(const SAM_ACCOUNT *sampass, + enum pdb_elements element) +{ + return (IS_SAM_SET(sampass, element) || + IS_SAM_CHANGED(sampass, element)); +} + /********************************************************************** Add SAM_ACCOUNT to LDAP *********************************************************************/ @@ -2066,7 +2091,8 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCO } } - if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd, True)) { + if (!init_ldap_from_sam(ldap_state, entry, &mods, newpwd, + element_is_set_or_changed)) { DEBUG(0, ("ldapsam_add_sam_account: init_ldap_from_sam failed!\n")); ldap_msgfree(result); ldap_mods_free(mods, 1); -- cgit From 85a1207a4702be62692544e794dea88c21095423 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 27 Mar 2003 16:33:59 +0000 Subject: Put backwards compatibility support for old modules in a seperate function (This used to be commit 2dd00078eec736797e65f69ad00297068e57cd9a) --- source3/smbd/vfs.c | 103 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 58 insertions(+), 45 deletions(-) (limited to 'source3') diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index cdff26ed1e..a8b350b9cd 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -196,21 +196,72 @@ static void vfs_init_default(connection_struct *conn) conn->vfs_private = NULL; } +/*************************************************************************** + Function to load old VFS modules. Should go away after a while. + **************************************************************************/ + +static BOOL vfs_load_old_plugin(connection_struct *conn, const char *vfs_object) +{ + int vfs_version = -1; + vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *); + /* Open object file */ + + if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) { + DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror())); + return False; + } + + /* Get handle on vfs_init() symbol */ + + init_fptr = (vfs_op_tuple *(*)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *))sys_dlsym(conn->vfs_private->handle, "vfs_init"); + + if (init_fptr == NULL) { + DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object)); + sys_dlclose(conn->vfs_private->handle); + return False; + } + + /* Initialise vfs_ops structure */ + if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) { + DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object)); + sys_dlclose(conn->vfs_private->handle); + return False; + } + + if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) { + DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", + vfs_version, SMB_VFS_INTERFACE_VERSION )); + sys_dlclose(conn->vfs_private->handle); + return False; + } + + if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) { + DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ + Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", + vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version )); + sys_dlclose(conn->vfs_private->handle); + return False; + } + + return True; +} + + + /**************************************************************************** initialise custom vfs hooks -****************************************************************************/ + ****************************************************************************/ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object) { - int vfs_version = -1; - vfs_op_tuple *ops, *(*init_fptr)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *); - int i; + vfs_op_tuple *ops; + int i; struct vfs_init_function_entry *entry; DEBUG(3, ("Initialising custom vfs hooks from %s\n", vfs_object)); if(!backends) static_init_vfs; - + /* First, try to load the module with the new module system */ if((entry = vfs_find_backend_entry(vfs_object)) || (smb_probe_module("vfs", vfs_object) && @@ -220,52 +271,14 @@ BOOL vfs_init_custom(connection_struct *conn, const char *vfs_object) if ((ops = entry->init(&conn->vfs_ops, conn->vfs_private)) == NULL) { DEBUG(0, ("vfs init function from %s failed\n", vfs_object)); - sys_dlclose(conn->vfs_private->handle); return False; } } else { /* If that doesn't work, fall back to the old system * (This part should go away after a while, it's only here * for backwards compatibility) */ - - /* Open object file */ - - if ((conn->vfs_private->handle = sys_dlopen(vfs_object, RTLD_NOW)) == NULL) { - DEBUG(0, ("Error opening %s: %s\n", vfs_object, sys_dlerror())); - return False; - } - - /* Get handle on vfs_init() symbol */ - - init_fptr = (vfs_op_tuple *(*)(int *, const struct vfs_ops *, struct smb_vfs_handle_struct *))sys_dlsym(conn->vfs_private->handle, "vfs_init"); - - if (init_fptr == NULL) { - DEBUG(0, ("No vfs_init() symbol found in %s\n", vfs_object)); - sys_dlclose(conn->vfs_private->handle); - return False; - } - - /* Initialise vfs_ops structure */ - if ((ops = init_fptr(&vfs_version, &conn->vfs_ops, conn->vfs_private)) == NULL) { - DEBUG(0, ("vfs_init() function from %s failed\n", vfs_object)); - sys_dlclose(conn->vfs_private->handle); - return False; - } - - if ((vfs_version < SMB_VFS_INTERFACE_CASCADED)) { - DEBUG(0, ("vfs_init() returned wrong interface version info (was %d, should be no less than %d)\n", - vfs_version, SMB_VFS_INTERFACE_VERSION )); - sys_dlclose(conn->vfs_private->handle); - return False; - } - - if ((vfs_version < SMB_VFS_INTERFACE_VERSION)) { - DEBUG(0, ("Warning: vfs_init() states that module confirms interface version #%d, current interface version is #%d.\n\ - Proceeding in compatibility mode, new operations (since version #%d) will fallback to default ones.\n", - vfs_version, SMB_VFS_INTERFACE_VERSION, vfs_version )); - sys_dlclose(conn->vfs_private->handle); - return False; - } + DEBUG(2, ("Can't load module with new modules system, falling back to old\n")); + if (!vfs_load_old_plugin(conn, vfs_object)) return False; } for(i=0; ops[i].op != NULL; i++) { -- cgit