From 10c82cf480185a01ff8e0a91bfb0cd4bf6707e37 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 7 Nov 2002 20:17:46 +0000 Subject: Back out lp_modules() check - this one got in by accident when I added poptSetOtherOptions (This used to be commit d7388b3e1e33a3514007e0e0b508469cb1ebed64) --- source3/utils/testparm.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index 451a15992b..280a7b8853 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -168,12 +168,6 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_ printf("'winbind separator = +' might cause problems with group membership.\n"); } -#ifndef HAVE_DLOPEN - if (lp_modules() != NULL) { - printf("'modules = ' specified in configuration file, but this samba build does not support plugins!\n"); - } -#endif - if (lp_algorithmic_rid_base() < BASE_RID) { /* Try to prevent admin foot-shooting, we can't put algorithmic rids below 1000, that's the 'well known RIDs' on NT */ -- cgit From 4d70634685fcd5f6a0d18d8cf1ce6aa0ae3ce4b7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 7 Nov 2002 21:39:51 +0000 Subject: Make append_log work again (This used to be commit 2fd496b49f76e3b593fb60fb2523a044a3814125) --- source3/smbd/server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 3d9a4675b2..1272fb1569 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -622,6 +622,7 @@ static void init_structs(void ) static BOOL is_daemon = False; static BOOL interactive = False; static char *ports = NULL; + extern BOOL append_log; int opt; poptContext pc; @@ -639,6 +640,8 @@ static void init_structs(void ) { NULL } }; + append_log = True; + #ifdef HAVE_SET_AUTH_PARAMETERS set_auth_parameters(argc,argv); #endif -- cgit From e1adcd154a9e4371b48eac40f01ac0ffc8103953 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 7 Nov 2002 22:45:11 +0000 Subject: Fix crash bug with overwriting memory. Jeremy. (This used to be commit 9b08b4e4c24290e5d90a7cc2dc442cb82e73df28) --- source3/printing/printing.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 6d4cc213a7..71e09c793f 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1111,7 +1111,7 @@ BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t struct tdb_print_db *pdb; TDB_DATA data; BOOL ret = True; - size_t i, num_pids; + size_t i, num_pids, offset; pid_t *pid_list; *p_num_pids = 0; @@ -1141,10 +1141,8 @@ BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t goto done; } - for( i = 0; i < data.dsize; i += 8) { - pid_t pid = (pid_t)IVAL(data.dptr, i); - pid_list[i] = pid; - } + for( i = 0, offset = 0; offset < data.dsize; offset += 8, i++) + pid_list[i] = (pid_t)IVAL(data.dptr, offset); *pp_pid_list = pid_list; *p_num_pids = num_pids; -- cgit From 5565aa9972bc47ae903a3186ac643b4651f49928 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Fri, 8 Nov 2002 01:34:58 +0000 Subject: Don't set global_machine_password_needs_changing if lp_machine_password_timeout() is set to zero. (This used to be commit 0fa87a68fea8b12242f644605aab7c2f81c1a4df) --- source3/auth/auth_domain.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index e18d809efb..f58e8bac47 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -510,10 +510,12 @@ static NTSTATUS check_ntdomain_security(const struct auth_context *auth_context, return NT_STATUS_CANT_ACCESS_DOMAIN_INFO; } - /* Test if machine password is expired and need to be changed */ - if (time(NULL) > last_change_time + lp_machine_password_timeout()) - { - global_machine_password_needs_changing = True; + /* Test if machine password has expired and needs to be changed */ + if (lp_machine_password_timeout()) { + if (time(NULL) > (last_change_time + + lp_machine_password_timeout())) { + global_machine_password_needs_changing = True; + } } /* -- cgit From 47035533781f49bd3cc1f4918c6b87c3904a02fe Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Nov 2002 18:44:57 +0000 Subject: patches from Urban (This used to be commit da269a73edb7f637b1e1f8b3dafe677f46f66f85) --- source3/lib/util_unistr.c | 2 ++ source3/libsmb/cliconnect.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index eb47252413..8e41581f75 100644 --- a/source3/lib/util_unistr.c +++ b/source3/lib/util_unistr.c @@ -335,6 +335,8 @@ smb_ucs2_t *strchr_w(const smb_ucs2_t *s, smb_ucs2_t c) if (c == *s) return (smb_ucs2_t *)s; s++; } + if (c == *s) return (smb_ucs2_t *)s; + return NULL; } diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index a404928a93..ee311932a7 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -124,6 +124,9 @@ static uint32 cli_session_setup_capabilities(struct cli_state *cli) if (cli->capabilities & CAP_UNICODE) capabilities |= CAP_UNICODE; + if (cli->capabilities & CAP_LARGE_FILES) + capabilities |= CAP_LARGE_FILES; + return capabilities; } -- cgit From eedcd7239b82bc9e249b74bb048964b600c95300 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 8 Nov 2002 19:06:34 +0000 Subject: Add enumkey command (EnumPrinterKey api) (This used to be commit a2e17d4344f996b64cd9c4f01b6b15c069fde41b) --- source3/rpcclient/cmd_spoolss.c | 76 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 8d18aed168..4ab6420f40 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1809,6 +1809,81 @@ done: return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } +/* enumerate subkeys */ + +static NTSTATUS cmd_spoolss_enum_printerkey( struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) +{ + WERROR result; + uint32 needed, returned; + BOOL got_hnd = False; + pstring printername; + fstring servername, user; + char *keyname = NULL; + POLICY_HND hnd; + uint16 *keylist = NULL, *curkey; + + if (argc < 2 || argc > 3) { + printf("Usage: %s printername [keyname]\n", argv[0]); + return NT_STATUS_OK; + } + + if (argc == 3) + keyname = argv[2]; + else + keyname = ""; + + /* Open printer handle */ + + slprintf(servername, sizeof(fstring)-1, "\\\\%s", cli->desthost); + strupper(servername); + fstrcpy(user, cli->user_name); + fstrcpy(printername, argv[1]); + slprintf(printername, sizeof(pstring)-1, "\\\\%s\\", cli->desthost); + strupper(printername); + pstrcat(printername, argv[1]); + + result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + "", MAXIMUM_ALLOWED_ACCESS, + servername, user, &hnd); + + if (!W_ERROR_IS_OK(result)) + goto done; + + got_hnd = True; + + /* Enumerate ports */ + + result = cli_spoolss_enumprinterkey( + cli, mem_ctx, 0, &needed, &hnd, keyname, NULL, NULL); + + if (W_ERROR_V(result) == ERRmoredata) + result = cli_spoolss_enumprinterkey( + cli, mem_ctx, needed, NULL, &hnd, keyname, &keylist, + &returned); + + if (!W_ERROR_IS_OK(result)) + goto done; + + curkey = keylist; + while (*curkey != 0) { + pstring subkey; + rpcstr_pull(subkey, curkey, sizeof(subkey), -1, + STR_TERMINATE); + printf("%s\n", subkey); + curkey += strlen(subkey) + 1; + } + + safe_free(keylist); + +done: + if (got_hnd) + cli_spoolss_close_printer(cli, mem_ctx, &hnd); + + return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; +} + static NTSTATUS cmd_spoolss_rffpcnex(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, char **argv) @@ -1897,6 +1972,7 @@ struct cmd_set spoolss_commands[] = { { "addprinter", cmd_spoolss_addprinterex, PI_SPOOLSS, "Add a printer", "" }, { "deldriver", cmd_spoolss_deletedriver, PI_SPOOLSS, "Delete a printer driver", "" }, { "enumdata", cmd_spoolss_not_implemented, PI_SPOOLSS, "Enumerate printer data (*)", "" }, + { "enumkey", cmd_spoolss_enum_printerkey, PI_SPOOLSS, "Enumerate printer keys", "" }, { "enumjobs", cmd_spoolss_enum_jobs, PI_SPOOLSS, "Enumerate print jobs", "" }, { "enumports", cmd_spoolss_enum_ports, PI_SPOOLSS, "Enumerate printer ports", "" }, { "enumdrivers", cmd_spoolss_enum_drivers, PI_SPOOLSS, "Enumerate installed printer drivers", "" }, -- cgit From 9429b7d8ab9f9dfba339774e9b287cf5ef379284 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 8 Nov 2002 20:51:04 +0000 Subject: Implement enumdata command (This used to be commit a22fdf26fef0cd58c84ca13891a762e3fdc6af8b) --- source3/rpcclient/cmd_spoolss.c | 87 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 4ab6420f40..5149c051e1 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1809,6 +1809,89 @@ done: return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } +static void display_reg_value(REGISTRY_VALUE value) +{ + pstring text; + + switch(value.type) { + case REG_DWORD: + printf("%s: REG_DWORD: 0x%08x\n", value.valuename, + *((uint32 *) value.data_p)); + break; + case REG_SZ: + rpcstr_pull(text, value.data_p, sizeof(text), value.size, + STR_TERMINATE); + printf("%s: REG_SZ: %s\n", value.valuename, text); + break; + case REG_BINARY: + printf("%s: REG_BINARY: unknown length value not displayed\n", + value.valuename); + break; + default: + printf("%s: unknown type %d\n", value.valuename, value.type); + } + +} +/* enumerate data */ + +static NTSTATUS cmd_spoolss_enum_data( struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) +{ + WERROR result; + uint32 i=0, val_needed, data_needed; + BOOL got_hnd = False; + pstring printername; + fstring servername, user; + POLICY_HND hnd; + + if (argc != 2) { + printf("Usage: %s printername\n", argv[0]); + return NT_STATUS_OK; + } + + /* Open printer handle */ + + slprintf(servername, sizeof(fstring)-1, "\\\\%s", cli->desthost); + strupper(servername); + fstrcpy(user, cli->user_name); + fstrcpy(printername, argv[1]); + slprintf(printername, sizeof(pstring)-1, "\\\\%s\\", cli->desthost); + strupper(printername); + pstrcat(printername, argv[1]); + + result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + "", MAXIMUM_ALLOWED_ACCESS, + servername, user, &hnd); + + if (!W_ERROR_IS_OK(result)) + goto done; + + got_hnd = True; + + /* Enumerate data */ + + result = cli_spoolss_enumprinterdata(cli, mem_ctx, &hnd, i, 0, 0, + &val_needed, &data_needed, + NULL); + while (W_ERROR_IS_OK(result)) { + REGISTRY_VALUE value; + result = cli_spoolss_enumprinterdata( + cli, mem_ctx, &hnd, i++, val_needed, + data_needed, 0, 0, &value); + if (W_ERROR_IS_OK(result)) + display_reg_value(value); + } + if (W_ERROR_V(result) == ERRnomoreitems) + result = W_ERROR(ERRsuccess); + +done: + if (got_hnd) + cli_spoolss_close_printer(cli, mem_ctx, &hnd); + + return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; +} + /* enumerate subkeys */ static NTSTATUS cmd_spoolss_enum_printerkey( struct cli_state *cli, @@ -1853,7 +1936,7 @@ static NTSTATUS cmd_spoolss_enum_printerkey( struct cli_state *cli, got_hnd = True; - /* Enumerate ports */ + /* Enumerate subkeys */ result = cli_spoolss_enumprinterkey( cli, mem_ctx, 0, &needed, &hnd, keyname, NULL, NULL); @@ -1971,7 +2054,7 @@ struct cmd_set spoolss_commands[] = { { "adddriver", cmd_spoolss_addprinterdriver, PI_SPOOLSS, "Add a print driver", "" }, { "addprinter", cmd_spoolss_addprinterex, PI_SPOOLSS, "Add a printer", "" }, { "deldriver", cmd_spoolss_deletedriver, PI_SPOOLSS, "Delete a printer driver", "" }, - { "enumdata", cmd_spoolss_not_implemented, PI_SPOOLSS, "Enumerate printer data (*)", "" }, + { "enumdata", cmd_spoolss_enum_data, PI_SPOOLSS, "Enumerate printer data", "" }, { "enumkey", cmd_spoolss_enum_printerkey, PI_SPOOLSS, "Enumerate printer keys", "" }, { "enumjobs", cmd_spoolss_enum_jobs, PI_SPOOLSS, "Enumerate print jobs", "" }, { "enumports", cmd_spoolss_enum_ports, PI_SPOOLSS, "Enumerate printer ports", "" }, -- cgit From 66a1f9b1fef10e7a74e8dafdfeefdf24f9096c13 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 8 Nov 2002 21:39:53 +0000 Subject: Add enumdataex command (This used to be commit 6d1d2849a7b2f99d927ba168ed2d01a879b09e69) --- source3/rpcclient/cmd_spoolss.c | 80 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 5149c051e1..4b5c6676e8 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1827,6 +1827,19 @@ static void display_reg_value(REGISTRY_VALUE value) printf("%s: REG_BINARY: unknown length value not displayed\n", value.valuename); break; + case REG_MULTI_SZ: { + uint16 *curstr = (uint16 *) value.data_p; + uint8 *start = value.data_p; + printf("%s: REG_MULTI_SZ:\n", value.valuename); + while ((*curstr != 0) && + ((uint8 *) curstr < start + value.size)) { + rpcstr_pull(text, curstr, sizeof(text), -1, + STR_TERMINATE); + printf(" %s\n", text); + curstr += strlen(text) + 1; + } + } + break; default: printf("%s: unknown type %d\n", value.valuename, value.type); } @@ -1892,6 +1905,72 @@ done: return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } +/* enumerate data for a given key */ + +static NTSTATUS cmd_spoolss_enum_data_ex( struct cli_state *cli, + TALLOC_CTX *mem_ctx, int argc, + char **argv) +{ + WERROR result; + uint32 needed, i; + BOOL got_hnd = False; + pstring printername; + fstring servername, user; + char *keyname = NULL; + POLICY_HND hnd; + REGVAL_CTR ctr; + + if (argc != 3) { + printf("Usage: %s printername \n", argv[0]); + return NT_STATUS_OK; + } + + keyname = argv[2]; + + /* Open printer handle */ + + slprintf(servername, sizeof(fstring)-1, "\\\\%s", cli->desthost); + strupper(servername); + fstrcpy(user, cli->user_name); + fstrcpy(printername, argv[1]); + slprintf(printername, sizeof(pstring)-1, "\\\\%s\\", cli->desthost); + strupper(printername); + pstrcat(printername, argv[1]); + + result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, + "", MAXIMUM_ALLOWED_ACCESS, + servername, user, &hnd); + + if (!W_ERROR_IS_OK(result)) + goto done; + + got_hnd = True; + + /* Enumerate subkeys */ + + result = cli_spoolss_enumprinterdataex( + cli, mem_ctx, 0, &needed, &hnd, keyname, NULL); + + if (W_ERROR_V(result) == ERRmoredata) + result = cli_spoolss_enumprinterdataex( + cli, mem_ctx, needed, NULL, &hnd, keyname, &ctr); + + if (!W_ERROR_IS_OK(result)) + goto done; + + for (i=0; i < ctr.num_values; i++) { + display_reg_value(*(ctr.values[i])); + } + + regval_ctr_destroy(&ctr); + +done: + if (got_hnd) + cli_spoolss_close_printer(cli, mem_ctx, &hnd); + + return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; +} + /* enumerate subkeys */ static NTSTATUS cmd_spoolss_enum_printerkey( struct cli_state *cli, @@ -2055,6 +2134,7 @@ struct cmd_set spoolss_commands[] = { { "addprinter", cmd_spoolss_addprinterex, PI_SPOOLSS, "Add a printer", "" }, { "deldriver", cmd_spoolss_deletedriver, PI_SPOOLSS, "Delete a printer driver", "" }, { "enumdata", cmd_spoolss_enum_data, PI_SPOOLSS, "Enumerate printer data", "" }, + { "enumdataex", cmd_spoolss_enum_data_ex, PI_SPOOLSS, "Enumerate printer data for a key", "" }, { "enumkey", cmd_spoolss_enum_printerkey, PI_SPOOLSS, "Enumerate printer keys", "" }, { "enumjobs", cmd_spoolss_enum_jobs, PI_SPOOLSS, "Enumerate print jobs", "" }, { "enumports", cmd_spoolss_enum_ports, PI_SPOOLSS, "Enumerate printer ports", "" }, -- cgit From d03b002d1280cc63b12c7fb3ec7635622d6ca0ca Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Nov 2002 22:13:34 +0000 Subject: Make smbpasswd tell people to use 'net join', not 'net rpc join' now we have the automagic detection. (This used to be commit a066bed5a4855dac955bf0bd7630939220314cfe) --- source3/utils/smbpasswd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 75a4319cb9..0e822ee7ad 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -122,7 +122,7 @@ static int process_options(int argc, char **argv, int local_flags) local_flags |= LOCAL_INTERDOM_ACCOUNT; break; case 'j': - d_printf("See 'net rpc join' for this functionality\n"); + d_printf("See 'net join' for this functionality\n"); exit(1); break; case 'n': -- cgit From aa208a58e260cfaec6abdc8560491d28b60d7380 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Nov 2002 22:14:31 +0000 Subject: Make it easier to track things down here - add some debugs on failure. (This used to be commit 62ee7b7dc08e7be261211de8f85b8e9be4df7b54) --- source3/rpc_server/srv_samr_nt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c index b039d92d9c..66556e3acb 100644 --- a/source3/rpc_server/srv_samr_nt.c +++ b/source3/rpc_server/srv_samr_nt.c @@ -303,6 +303,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) } if (!pdb_enum_group_mapping(SID_NAME_DOM_GRP, &map, (int *)&group_entries, ENUM_ONLY_MAPPED, MAPPING_WITHOUT_PRIV)) { + DEBUG(1, ("load_group_domain_entries: pdb_enum_group_mapping() failed!\n")); return NT_STATUS_NO_MEMORY; } @@ -311,6 +312,7 @@ static NTSTATUS load_group_domain_entries(struct samr_info *info, DOM_SID *sid) grp_array=(DISP_GROUP_INFO *)talloc(mem_ctx, info->disp_info.num_group_account*sizeof(DISP_GROUP_INFO)); if (group_entries!=0 && grp_array==NULL) { + DEBUG(1, ("load_group_domain_entries: talloc() failed for grp_array!\n")); SAFE_FREE(map); return NT_STATUS_NO_MEMORY; } -- cgit From 48b32cd865b572c797e6f5de1b8a574bd86e250a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Nov 2002 22:15:34 +0000 Subject: Make smbpasswd use the group mapping, and fix spelling in ldapsam. This gets user mangler for doamins working again. Andrew Bartlett (This used to be commit 205209f77f154a2a5d5f7a255194d7953860a4db) --- source3/passdb/pdb_ldap.c | 28 ++++++++++++++-------------- source3/passdb/pdb_smbpasswd.c | 40 ++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 22358cb47d..e35775a6da 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -1907,49 +1907,49 @@ static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCO return NT_STATUS_OK; } -static NTSTATUS lsapsam_getgrsid(struct pdb_methods *methods, GROUP_MAP *map, +static NTSTATUS ldapsam_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 lsapsam_getgrgid(struct pdb_methods *methods, GROUP_MAP *map, +static NTSTATUS ldapsam_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 lsapsam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map, +static NTSTATUS ldapsam_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 lsapsam_add_group_mapping_entry(struct pdb_methods *methods, +static NTSTATUS ldapsam_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 lsapsam_update_group_mapping_entry(struct pdb_methods *methods, +static NTSTATUS ldapsam_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 lsapsam_delete_group_mapping_entry(struct pdb_methods *methods, +static NTSTATUS ldapsam_delete_group_mapping_entry(struct pdb_methods *methods, DOM_SID sid) { return group_map_remove(sid) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } -static NTSTATUS lsapsam_enum_group_mapping(struct pdb_methods *methods, +static NTSTATUS ldapsam_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) @@ -1998,13 +1998,13 @@ NTSTATUS pdb_init_ldapsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, co (*pdb_method)->add_sam_account = ldapsam_add_sam_account; (*pdb_method)->update_sam_account = ldapsam_update_sam_account; (*pdb_method)->delete_sam_account = ldapsam_delete_sam_account; - (*pdb_method)->getgrsid = lsapsam_getgrsid; - (*pdb_method)->getgrgid = lsapsam_getgrgid; - (*pdb_method)->getgrnam = lsapsam_getgrnam; - (*pdb_method)->add_group_mapping_entry = lsapsam_add_group_mapping_entry; - (*pdb_method)->update_group_mapping_entry = lsapsam_update_group_mapping_entry; - (*pdb_method)->delete_group_mapping_entry = lsapsam_delete_group_mapping_entry; - (*pdb_method)->enum_group_mapping = lsapsam_enum_group_mapping; + (*pdb_method)->getgrsid = ldapsam_getgrsid; + (*pdb_method)->getgrgid = ldapsam_getgrgid; + (*pdb_method)->getgrnam = ldapsam_getgrnam; + (*pdb_method)->add_group_mapping_entry = ldapsam_add_group_mapping_entry; + (*pdb_method)->update_group_mapping_entry = ldapsam_update_group_mapping_entry; + (*pdb_method)->delete_group_mapping_entry = ldapsam_delete_group_mapping_entry; + (*pdb_method)->enum_group_mapping = ldapsam_enum_group_mapping; /* TODO: Setup private data and free */ diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index abfe016e8a..5fd6a828bf 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -1494,47 +1494,55 @@ static NTSTATUS smbpasswd_delete_sam_account (struct pdb_methods *my_methods, SA } static NTSTATUS smbpasswd_getgrsid(struct pdb_methods *methods, GROUP_MAP *map, - DOM_SID sid, BOOL with_priv) + DOM_SID sid, BOOL with_priv) { - return NT_STATUS_NOT_IMPLEMENTED; + return get_group_map_from_sid(sid, map, with_priv) ? + NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static NTSTATUS smbpasswd_getgrgid(struct pdb_methods *methods, GROUP_MAP *map, - gid_t gid, BOOL with_priv) + gid_t gid, BOOL with_priv) { - return NT_STATUS_NOT_IMPLEMENTED; + return get_group_map_from_gid(gid, map, with_priv) ? + NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static NTSTATUS smbpasswd_getgrnam(struct pdb_methods *methods, GROUP_MAP *map, - char *name, BOOL with_priv) + char *name, BOOL with_priv) { - return NT_STATUS_NOT_IMPLEMENTED; + return get_group_map_from_ntname(name, map, with_priv) ? + NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static NTSTATUS smbpasswd_add_group_mapping_entry(struct pdb_methods *methods, - GROUP_MAP *map) + GROUP_MAP *map) { - return NT_STATUS_NOT_IMPLEMENTED; + return add_mapping_entry(map, TDB_INSERT) ? + NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static NTSTATUS smbpasswd_update_group_mapping_entry(struct pdb_methods *methods, - GROUP_MAP *map) + GROUP_MAP *map) { - return NT_STATUS_NOT_IMPLEMENTED; + return add_mapping_entry(map, TDB_REPLACE) ? + NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static NTSTATUS smbpasswd_delete_group_mapping_entry(struct pdb_methods *methods, - DOM_SID sid) + DOM_SID sid) { - return NT_STATUS_NOT_IMPLEMENTED; + return group_map_remove(sid) ? + NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static NTSTATUS smbpasswd_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) + enum SID_NAME_USE sid_name_use, + GROUP_MAP **rmap, int *num_entries, + BOOL unix_only, BOOL with_priv) { - return NT_STATUS_NOT_IMPLEMENTED; + return enum_group_mapping(sid_name_use, rmap, num_entries, unix_only, + with_priv) ? + NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static void free_private_data(void **vp) -- cgit From c501ac2bfa4b9fa88c402bb0313312ea0f565443 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Nov 2002 23:05:34 +0000 Subject: Compleatly remove support for logfile truncation. All logs are opened for append writes. (blessed by jra) Andrew Bartlett (This used to be commit 81633064dd196c40541ecece8def51745f514646) --- source3/lib/debug.c | 13 ++----------- source3/nmbd/nmbd.c | 5 ----- source3/nsswitch/winbindd.c | 6 ------ source3/smbd/server.c | 3 --- source3/wrepld/server.c | 11 ----------- 5 files changed, 2 insertions(+), 36 deletions(-) diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 483db71b85..f2a362bb86 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -74,15 +74,12 @@ * * dbf - Global debug file handle. * debugf - Debug file name. - * append_log - If True, then the output file will be opened in append - * mode. * DEBUGLEVEL - System-wide debug message limit. Messages with message- * levels higher than DEBUGLEVEL will not be processed. */ XFILE *dbf = NULL; pstring debugf = ""; -BOOL append_log = False; BOOL debug_warn_unknown_class = True; BOOL debug_auto_add_unknown_class = True; BOOL AllowDebugChange = True; @@ -576,10 +573,7 @@ BOOL reopen_logs( void ) } pstrcpy( debugf, fname ); - if (append_log) - new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644); - else - new_dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 ); + new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644); if (!new_dbf) { log_overflow = True; @@ -731,10 +725,7 @@ void check_log_size( void ) { mode_t oldumask = umask( 022 ); - if( append_log ) - dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 ); - else - dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 ); + dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 ); (void)umask( oldumask ); if( dbf ) { diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 9f4a934fae..50730d40f3 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -661,15 +661,12 @@ static BOOL init_structs(void) **************************************************************************** */ int main(int argc, const char *argv[]) { - extern BOOL append_log; static BOOL opt_interactive = False; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP {"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon(default)" }, - {"log-append", 'a', POPT_ARG_VAL, &append_log, True, "Append to log file" }, {"interactive", 'i', POPT_ARG_VAL, &opt_interactive, True, "Run interactive (not a daemon)" }, - {"log-overwrite", 'o', POPT_ARG_VAL, &append_log, False, "Overwrite log file, don't append" }, {"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" }, {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, @@ -683,8 +680,6 @@ static BOOL init_structs(void) int opt; pstring logfile; - append_log = True; /* Default, override with '-o' option. */ - global_nmb_port = NMB_PORT; global_in_nmbd = True; diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c index 059d2f40d3..2bd6d7967c 100644 --- a/source3/nsswitch/winbindd.c +++ b/source3/nsswitch/winbindd.c @@ -746,7 +746,6 @@ static void usage(void) extern BOOL AllowDebugChange; extern pstring global_myname; extern fstring global_myworkgroup; - extern BOOL append_log; pstring logfile; BOOL interactive = False; int opt; @@ -759,11 +758,6 @@ static void usage(void) fault_setup((void (*)(void *))fault_quit ); - /* Append to log file by default as we are a single process daemon - program. */ - - append_log = True; - snprintf(logfile, sizeof(logfile), "%s/log.winbindd", dyn_LOGFILEBASE); lp_set_logfile(logfile); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 1272fb1569..3d9a4675b2 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -622,7 +622,6 @@ static void init_structs(void ) static BOOL is_daemon = False; static BOOL interactive = False; static char *ports = NULL; - extern BOOL append_log; int opt; poptContext pc; @@ -640,8 +639,6 @@ static void init_structs(void ) { NULL } }; - append_log = True; - #ifdef HAVE_SET_AUTH_PARAMETERS set_auth_parameters(argc,argv); #endif diff --git a/source3/wrepld/server.c b/source3/wrepld/server.c index 14d3e730f4..f08674afbb 100644 --- a/source3/wrepld/server.c +++ b/source3/wrepld/server.c @@ -541,7 +541,6 @@ static void process(void) ****************************************************************************/ int main(int argc,char *argv[]) { - extern BOOL append_log; extern char *optarg; /* shall I run as a daemon */ BOOL is_daemon = False; @@ -576,18 +575,10 @@ static void process(void) lp_set_logfile(logfile); break; - case 'a': - append_log = True; - break; - case 'i': interactive = True; break; - case 'o': - append_log = False; - break; - case 'D': is_daemon = True; break; @@ -628,8 +619,6 @@ static void process(void) load_case_tables(); - append_log = True; - if(!specified_logfile) { slprintf(logfile, sizeof(logfile)-1, "%s/log.wrepld", dyn_LOGFILEBASE); -- cgit From cc9b6ef9cadf31b576609308d24657e921c644d1 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 8 Nov 2002 23:46:45 +0000 Subject: defunct winbindd fix from APP_HEAD (This used to be commit 488e985caa0b0e3e2a6665eb2515a2c99745d861) --- source3/nsswitch/winbindd_dual.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source3/nsswitch/winbindd_dual.c b/source3/nsswitch/winbindd_dual.c index a7523138ea..f31a4f2de4 100644 --- a/source3/nsswitch/winbindd_dual.c +++ b/source3/nsswitch/winbindd_dual.c @@ -143,7 +143,7 @@ void do_dual_daemon(void) { int fdpair[2]; struct winbindd_cli_state state; - + if (pipe(fdpair) != 0) { return; } @@ -160,7 +160,12 @@ void do_dual_daemon(void) } close(fdpair[1]); - if (winbind_setup_common() != 0) _exit(0); + + sleep (60); + DEBUG(0,("do_dual_daemon: Starting up....\n")); + + if (!winbind_setup_common()) + _exit(0); dual_daemon_pipe = -1; opt_dual_daemon = False; -- cgit From 5fabbb0573095d05695ab4904683f6939d6d9e37 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Sat, 9 Nov 2002 01:47:54 +0000 Subject: Rewrite all the packing stuff so that it converts 'f' strings to CP850 on encoding. (Tough luck if your Samba codepage is not 850.) It's much cleaner and possibly more efficient now too: just build one big list of strings, then zip it up at the end. Still need to do this for unpacking. (This used to be commit 2480d385db0527b71cc5cd23c4fab4655df84485) --- source3/python/py_tdbpack.c | 448 +++++++++++++++++++++++++++----------------- 1 file changed, 274 insertions(+), 174 deletions(-) diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c index 87cd804ed4..7180c3e12c 100644 --- a/source3/python/py_tdbpack.c +++ b/source3/python/py_tdbpack.c @@ -27,16 +27,17 @@ #include "Python.h" -static int pytdbpack_calc_reqd_len(char *format_str, - PyObject *val_seq); +static PyObject * pytdbpack_number(char ch, PyObject *val_iter, PyObject *packed_list); +static PyObject * pytdbpack_str_850(PyObject *val_iter, PyObject *packed_list); +static PyObject * pytdbpack_buffer(PyObject *val_iter, PyObject *packed_list); static PyObject *pytdbpack_unpack_item(char, char **pbuf, int *plen, PyObject *); -static PyObject *pytdbpack_pack_data(const char *format_str, +static PyObject *pytdbpack_data(const char *format_str, PyObject *val_seq, - unsigned char *buf); - + PyObject *val_list); +static void pack_le_uint32(unsigned long val_long, unsigned char *pbuf); static PyObject *pytdbpack_bad_type(char ch, @@ -57,13 +58,17 @@ tdb/tdbutil module, with appropriate adjustments for Python datatypes. Python strings are used to specify the format of data to be packed or unpacked. -Strings in TDBs are typically stored in DOS codepages. The caller of this -module must make appropriate translations if necessary, typically to and from -Unicode objects. +Strings are always stored in codepage 850. Unicode objects are translated +to cp850; plain strings are assumed to be in latin-1 and are also +translated. + +This may be a problem in the future if it is different to the Samba codepage. +It might be better to have the caller do the conversion, but that would conflict +with existing CMI code. tdbpack format strings: - 'f': NULL-terminated string in DOS codepage + 'f': NULL-terminated string in codepage 850 'P': same as 'f' @@ -88,7 +93,7 @@ tdbpack format strings: "; -static char const pytdbpack_pack_doc[] = +static char const pytdbpack_doc[] = "pack(format, values) -> buffer Pack Python objects into Samba binary format according to format string. @@ -141,65 +146,274 @@ notes: + /* - Game plan is to first of all walk through the arguments and calculate the - total length that will be required. We allocate a Python string of that - size, then walk through again and fill it in. - - We just borrow references to all the passed arguments, since none of them - need to be permanently stored. We transfer ownership to the returned - object. - */ + * Pack objects to bytes. + * + * All objects are first individually encoded onto a list, and then the list + * of strings is concatenated. This is faster than concatenating strings, + * and reasonably simple to code. + */ static PyObject * -pytdbpack_pack(PyObject *self, +pytdbpack(PyObject *self, PyObject *args) { char *format_str; - PyObject *val_seq, *fast_seq, *buf_str; - int reqd_len; - char *packed_buf; + PyObject *val_seq, *val_iter = NULL, + *packed_list = NULL, *packed_str = NULL, + *empty_str = NULL; /* TODO: Test passing wrong types or too many arguments */ if (!PyArg_ParseTuple(args, "sO", &format_str, &val_seq)) return NULL; - /* Convert into a list or tuple (if not already one), so that we can - * index more easily. */ - fast_seq = PySequence_Fast(val_seq, - __FUNCTION__ ": argument 2 must be sequence"); - if (!fast_seq) - return NULL; - - reqd_len = pytdbpack_calc_reqd_len(format_str, fast_seq); - if (reqd_len == -1) /* exception was thrown */ - return NULL; + if (!(val_iter = PyObject_GetIter(val_seq))) + goto out; - /* Allocate space. - - This design causes an unnecessary copying of the data when Python - constructs an object, and that might possibly be avoided by using a - Buffer object of some kind instead. I'm not doing that for now - though. */ - packed_buf = malloc(reqd_len); - if (!packed_buf) { - PyErr_Format(PyExc_MemoryError, - "%s: couldn't allocate %d bytes for packed buffer", - __FUNCTION__, reqd_len); - return NULL; - } + /* Create list to hold strings until we're done, then join them all. */ + if (!(packed_list = PyList_New(0))) + goto out; + + if (!pytdbpack_data(format_str, val_iter, packed_list)) + goto out; + + /* this function is not officially documented but it works */ + if (!(empty_str = PyString_InternFromString(""))) + goto out; - if (!pytdbpack_pack_data(format_str, fast_seq, packed_buf)) { - free(packed_buf); - return NULL; + packed_str = _PyString_Join(empty_str, packed_list); + + out: + Py_XDECREF(empty_str); + Py_XDECREF(val_iter); + Py_XDECREF(packed_list); + + return packed_str; +} + + +/* + Pack data according to FORMAT_STR from the elements of VAL_SEQ into + PACKED_BUF. + + The string has already been checked out, so we know that VAL_SEQ is large + enough to hold the packed data, and that there are enough value items. + (However, their types may not have been thoroughly checked yet.) + + In addition, val_seq is a Python Fast sequence. + + Returns NULL for error (with exception set), or None. +*/ +PyObject * +pytdbpack_data(const char *format_str, + PyObject *val_iter, + PyObject *packed_list) +{ + int format_i, val_i = 0; + + for (format_i = 0, val_i = 0; format_str[format_i]; format_i++) { + char ch = format_str[format_i]; + + switch (ch) { + /* dispatch to the appropriate packer for this type, + which should pull things off the iterator, and + append them to the packed_list */ + case 'w': + case 'd': + case 'p': + if (!(packed_list = pytdbpack_number(ch, val_iter, packed_list))) + return NULL; + break; + + case 'f': + case 'P': + if (!(packed_list = pytdbpack_str_850(val_iter, packed_list))) + return NULL; + break; + + case 'B': + if (!(packed_list = pytdbpack_buffer(val_iter, packed_list))) + return NULL; + break; + + default: + PyErr_Format(PyExc_ValueError, + "%s: format character '%c' is not supported", + __FUNCTION__, ch); + return NULL; + } + } + + return packed_list; +} + + +static PyObject * +pytdbpack_number(char ch, PyObject *val_iter, PyObject *packed_list) +{ + unsigned long val_long; + PyObject *val_obj = NULL, *long_obj = NULL, *result_obj = NULL; + PyObject *new_list = NULL; + unsigned char pack_buf[4]; + + if (!(val_obj = PyIter_Next(val_iter))) + goto out; + + if (!(long_obj = PyNumber_Long(val_obj))) { + pytdbpack_bad_type(ch, "Number", val_obj); + goto out; } - buf_str = PyString_FromStringAndSize(packed_buf, reqd_len); - free(packed_buf); /* get rid of tmp buf */ + val_long = PyLong_AsUnsignedLong(long_obj); + pack_le_uint32(val_long, pack_buf); + + /* pack as 32-bit; if just packing a 'w' 16-bit word then only take + the first two bytes. */ - return buf_str; + if (!(result_obj = PyString_FromStringAndSize(pack_buf, ch == 'w' ? 2 : 4))) + goto out; + + if (PyList_Append(packed_list, result_obj) != -1) + new_list = packed_list; + + out: + Py_XDECREF(val_obj); + Py_XDECREF(long_obj); + Py_XDECREF(result_obj); + + return new_list; +} + + +/* + * Take one string from the iterator val_iter, convert it to 8-bit CP850, and + * return it. + * + * If the input is neither a string nor Unicode, an exception is raised. + * + * If the input is Unicode, then it is converted to CP850. + * + * If the input is a String, then it is converted to Unicode using the default + * decoding method, and then converted to CP850. This in effect gives + * conversion from latin-1 (currently the PSA's default) to CP850, without + * needing a custom translation table. + * + * I hope this approach avoids being too fragile w.r.t. being passed either + * Unicode or String objects. + */ +static PyObject * +pytdbpack_str_850(PyObject *val_iter, PyObject *packed_list) +{ + PyObject *val_obj = NULL; + PyObject *unicode_obj = NULL; + PyObject *cp850_str = NULL; + PyObject *nul_str = NULL; + PyObject *new_list = NULL; + + if (!(val_obj = PyIter_Next(val_iter))) + goto out; + + if (PyUnicode_Check(val_obj)) { + unicode_obj = val_obj; + } + else { + /* string */ + if (!(unicode_obj = PyString_AsDecodedObject(val_obj, NULL, NULL))) + goto out; + Py_XDECREF(val_obj); + val_obj = NULL; + } + + if (!(cp850_str = PyUnicode_AsEncodedString(unicode_obj, "cp850", NULL))) + goto out; + + if (!nul_str) + /* this is constant and often-used; hold it forever */ + if (!(nul_str = PyString_FromStringAndSize("", 1))) + goto out; + + if ((PyList_Append(packed_list, cp850_str) != -1) + && (PyList_Append(packed_list, nul_str) != -1)) + new_list = packed_list; + + out: + Py_XDECREF(unicode_obj); + Py_XDECREF(cp850_str); + + return new_list; } +/* + * Pack (LENGTH, BUFFER) pair onto the list. + * + * The buffer must already be a String, not Unicode, because it contains 8-bit + * untranslated data. In some cases it will actually be UTF_16_LE data. + */ +static PyObject * +pytdbpack_buffer(PyObject *val_iter, PyObject *packed_list) +{ + PyObject *val_obj; + PyObject *new_list = NULL; + + /* pull off integer and stick onto list */ + if (!(packed_list = pytdbpack_number('d', val_iter, packed_list))) + return NULL; + + /* this assumes that the string is the right length; the old code did the same. */ + if (!(val_obj = PyIter_Next(val_iter))) + return NULL; + + if (!PyString_Check(val_obj)) { + pytdbpack_bad_type('B', "String", val_obj); + goto out; + } + + if (PyList_Append(packed_list, val_obj) != -1) + new_list = packed_list; + + out: + Py_XDECREF(val_obj); + return new_list; +} + + +#if 0 +else if (ch == 'B') { + long size; + char *sval; + + if (!PyNumber_Check(val_obj)) { + pytdbpack_bad_type(ch, "Number", val_obj); + return NULL; + } + + if (!(val_obj = PyNumber_Long(val_obj))) + return NULL; + + size = PyLong_AsLong(val_obj); + pack_le_uint32(size, &packed); + + /* Release the new reference created by the cast */ + Py_DECREF(val_obj); + + val_obj = PySequence_GetItem(val_seq, val_i++); + if (!val_obj) + return NULL; + + sval = PyString_AsString(val_obj); + if (!sval) + return NULL; + + pack_bytes(size, sval, &packed); /* do not include nul */ + } + else { + + } + + return Py_None; +} +#endif static PyObject * pytdbpack_unpack(PyObject *self, @@ -270,6 +484,8 @@ pytdbpack_unpack(PyObject *self, } + +#if 0 /* Internal routine that calculates how many bytes will be required to encode the values in the format. @@ -361,6 +577,7 @@ pytdbpack_calc_reqd_len(char *format_str, return len; } +#endif static PyObject *pytdbpack_bad_type(char ch, @@ -384,13 +601,12 @@ static PyObject *pytdbpack_bad_type(char ch, realize this is kind of dumb because we'll almost always be on x86, but being safe is important. */ -static void pack_uint32(unsigned long val_long, unsigned char **pbuf) +static void pack_le_uint32(unsigned long val_long, unsigned char *pbuf) { - (*pbuf)[0] = val_long & 0xff; - (*pbuf)[1] = (val_long >> 8) & 0xff; - (*pbuf)[2] = (val_long >> 16) & 0xff; - (*pbuf)[3] = (val_long >> 24) & 0xff; - (*pbuf) += 4; + pbuf[0] = val_long & 0xff; + pbuf[1] = (val_long >> 8) & 0xff; + pbuf[2] = (val_long >> 16) & 0xff; + pbuf[3] = (val_long >> 24) & 0xff; } @@ -581,126 +797,10 @@ static PyObject *pytdbpack_unpack_item(char ch, -/* - Pack data according to FORMAT_STR from the elements of VAL_SEQ into - PACKED_BUF. - - The string has already been checked out, so we know that VAL_SEQ is large - enough to hold the packed data, and that there are enough value items. - (However, their types may not have been thoroughly checked yet.) - - In addition, val_seq is a Python Fast sequence. - - Returns NULL for error (with exception set), or None. -*/ -PyObject * -pytdbpack_pack_data(const char *format_str, - PyObject *val_seq, - unsigned char *packed) -{ - int format_i, val_i = 0; - - for (format_i = 0, val_i = 0; format_str[format_i]; format_i++) { - char ch = format_str[format_i]; - PyObject *val_obj; - - /* borrow a reference to the item */ - val_obj = PySequence_GetItem(val_seq, val_i++); - if (!val_obj) - return NULL; - - if (ch == 'w') { - unsigned long val_long; - PyObject *long_obj; - - if (!(long_obj = PyNumber_Long(val_obj))) { - pytdbpack_bad_type(ch, "Long", val_obj); - return NULL; - } - - val_long = PyLong_AsUnsignedLong(long_obj); - (packed)[0] = val_long & 0xff; - (packed)[1] = (val_long >> 8) & 0xff; - (packed) += 2; - Py_DECREF(long_obj); - } - else if (ch == 'd') { - /* 4-byte LE number */ - PyObject *long_obj; - - if (!(long_obj = PyNumber_Long(val_obj))) { - pytdbpack_bad_type(ch, "Long", val_obj); - return NULL; - } - - pack_uint32(PyLong_AsUnsignedLong(long_obj), &packed); - - Py_DECREF(long_obj); - } - else if (ch == 'p') { - /* "Pointer" value -- in the subset of DCERPC used by Samba, - this is really just an "exists" or "does not exist" - flag. */ - pack_uint32(PyObject_IsTrue(val_obj), &packed); - } - else if (ch == 'f' || ch == 'P') { - int size; - char *sval; - - size = PySequence_Length(val_obj); - if (size < 0) - return NULL; - sval = PyString_AsString(val_obj); - if (!sval) - return NULL; - pack_bytes(size+1, sval, &packed); /* include nul */ - } - else if (ch == 'B') { - long size; - char *sval; - - if (!PyNumber_Check(val_obj)) { - pytdbpack_bad_type(ch, "Number", val_obj); - return NULL; - } - - if (!(val_obj = PyNumber_Long(val_obj))) - return NULL; - - size = PyLong_AsLong(val_obj); - pack_uint32(size, &packed); - - /* Release the new reference created by the cast */ - Py_DECREF(val_obj); - - val_obj = PySequence_GetItem(val_seq, val_i++); - if (!val_obj) - return NULL; - - sval = PyString_AsString(val_obj); - if (!sval) - return NULL; - - pack_bytes(size, sval, &packed); /* do not include nul */ - } - else { - /* this ought to be caught while calculating the length, but - just in case. */ - PyErr_Format(PyExc_ValueError, - "%s: format character '%c' is not supported", - __FUNCTION__, ch); - - return NULL; - } - } - - return Py_None; -} - static PyMethodDef pytdbpack_methods[] = { - { "pack", pytdbpack_pack, METH_VARARGS, (char *) pytdbpack_pack_doc }, + { "pack", pytdbpack, METH_VARARGS, (char *) pytdbpack_doc }, { "unpack", pytdbpack_unpack, METH_VARARGS, (char *) pytdbpack_unpack_doc }, }; -- cgit From 8ce292d96f4841861ee8caf60278cafdfd6b9f55 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 9 Nov 2002 02:36:47 +0000 Subject: Fix bug where not specifying '-S PDC' in 'net join' would cause it to attempt to contact a random IP address. Andrew Bartlett (This used to be commit e6837a85605f258da1fa9ac7ad329bc62392f29a) --- source3/utils/net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source3/utils/net.c b/source3/utils/net.c index 607e47cf71..4b1a52992e 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -192,6 +192,7 @@ BOOL net_find_server(unsigned flags, struct in_addr *server_ip, char **server_na return False; *server_name = strdup(dc_name); + *server_ip = pdc_ip; } } else if (flags & NET_FLAGS_DMB) { -- cgit From 02c58f3fb92c18ffb31c77a397163c44d70e3c93 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 9 Nov 2002 03:37:01 +0000 Subject: Add chainlock_read functions to get a read lock. Used in *massively* contended tdb's (and I've got one :-). Jeremy. (This used to be commit 064fa201ab73f476a168c40c2b227507e7342ec4) --- source3/tdb/tdb.c | 12 +++++++++++- source3/tdb/tdbutil.c | 43 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index 2a6dca16a8..e539376ac7 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -186,7 +186,7 @@ static int tdb_brlock(TDB_CONTEXT *tdb, tdb_off offset, if (tdb->flags & TDB_NOLOCK) return 0; - if (tdb->read_only) { + if ((rw_type == F_WRLCK) && (tdb->read_only)) { errno = EACCES; return -1; } @@ -1802,6 +1802,16 @@ int tdb_chainunlock(TDB_CONTEXT *tdb, TDB_DATA key) return tdb_unlock(tdb, BUCKET(tdb_hash(&key)), F_WRLCK); } +int tdb_chainlock_read(TDB_CONTEXT *tdb, TDB_DATA key) +{ + return tdb_lock(tdb, BUCKET(tdb_hash(&key)), F_RDLCK); +} + +int tdb_chainunlock_read(TDB_CONTEXT *tdb, TDB_DATA key) +{ + return tdb_unlock(tdb, BUCKET(tdb_hash(&key)), F_RDLCK); +} + /* register a loging function */ void tdb_logging_function(TDB_CONTEXT *tdb, void (*fn)(TDB_CONTEXT *, int , const char *, ...)) diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c index ad97f45044..5498872f8a 100644 --- a/source3/tdb/tdbutil.c +++ b/source3/tdb/tdbutil.c @@ -39,7 +39,7 @@ static void gotalarm_sig(void) Lock a chain with timeout (in seconds). ****************************************************************************/ -int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout) +static int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int timeout, int rw_type) { /* Allow tdb_chainlock to be interrupted by an alarm. */ int ret; @@ -51,13 +51,19 @@ int tdb_chainlock_with_timeout( TDB_CONTEXT *tdb, TDB_DATA key, unsigned int tim alarm(timeout); } - ret = tdb_chainlock(tdb, key); + if (rw_type == F_RDLCK) + ret = tdb_chainlock_read(tdb, key); + else + ret = tdb_chainlock(tdb, key); if (timeout) { alarm(0); CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); - if (gotalarm) + if (gotalarm) { + DEBUG(0,("tdb_chainlock_with_timeout: alarm (%u) timed out for key %s in tdb %s\n", + timeout, key.dptr, tdb->name )); return -1; + } } return ret; @@ -74,7 +80,7 @@ int tdb_lock_bystring(TDB_CONTEXT *tdb, char *keyval, unsigned int timeout) key.dptr = keyval; key.dsize = strlen(keyval)+1; - return tdb_chainlock_with_timeout(tdb, key, timeout); + return tdb_chainlock_with_timeout(tdb, key, timeout, F_WRLCK); } /**************************************************************************** @@ -91,6 +97,35 @@ void tdb_unlock_bystring(TDB_CONTEXT *tdb, char *keyval) tdb_chainunlock(tdb, key); } +/**************************************************************************** + Read lock a chain by string. Return -1 if timeout or lock failed. +****************************************************************************/ + +int tdb_read_lock_bystring(TDB_CONTEXT *tdb, char *keyval, unsigned int timeout) +{ + TDB_DATA key; + + key.dptr = keyval; + key.dsize = strlen(keyval)+1; + + return tdb_chainlock_with_timeout(tdb, key, timeout, F_RDLCK); +} + +/**************************************************************************** + Read unlock a chain by string. +****************************************************************************/ + +void tdb_read_unlock_bystring(TDB_CONTEXT *tdb, char *keyval) +{ + TDB_DATA key; + + key.dptr = keyval; + key.dsize = strlen(keyval)+1; + + tdb_chainunlock_read(tdb, key); +} + + /**************************************************************************** Fetch a int32 value by a arbitrary blob key, return -1 if not found. Output is int32 in native byte order. -- cgit From 5a21d8021a487da81b4b3389ee628763c651edae Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sat, 9 Nov 2002 03:57:28 +0000 Subject: Fix bug found by tpot with given password server. Jeremy. (This used to be commit 90ac8184a0ae1f702d39f947ef5267765f3d2f88) --- source3/auth/auth_domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/auth/auth_domain.c b/source3/auth/auth_domain.c index f58e8bac47..9d4824fbc7 100644 --- a/source3/auth/auth_domain.c +++ b/source3/auth/auth_domain.c @@ -396,7 +396,7 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx, nt_status = find_connect_pdc(&cli, domain, setup_creds_as, sec_chan, trust_passwd, last_change_time); } else { int i; - BOOL retry = False; + BOOL retry = True; for (i = 0; !NT_STATUS_IS_OK(nt_status) && retry && (i < 3); i++) nt_status = connect_to_domain_password_server(&cli, remote_machine, setup_creds_as, sec_chan, trust_passwd, &retry); -- cgit From 5d81628512d92f1d997fdb5bec21818135384d7b Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 9 Nov 2002 04:37:07 +0000 Subject: remove accidental debug code.. (This used to be commit d422a51b3a076b6398f7b755d16319d9e7c48c75) --- source3/nsswitch/winbindd_dual.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source3/nsswitch/winbindd_dual.c b/source3/nsswitch/winbindd_dual.c index f31a4f2de4..207757bcea 100644 --- a/source3/nsswitch/winbindd_dual.c +++ b/source3/nsswitch/winbindd_dual.c @@ -159,10 +159,6 @@ void do_dual_daemon(void) return; } close(fdpair[1]); - - - sleep (60); - DEBUG(0,("do_dual_daemon: Starting up....\n")); if (!winbind_setup_common()) _exit(0); -- cgit From b3f55b37a09551b6e782e58b3339b9caa4086d6d Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 9 Nov 2002 05:41:27 +0000 Subject: re-enable ffpcn on print server handle (This used to be commit e87829b4942237de542d21051092fee069a9c73d) --- source3/rpc_server/srv_spoolss_nt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 245df2003f..5ebefc5ea0 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -2477,7 +2477,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE return WERR_BADFID; } - if (!get_printer_snum(p, handle, &snum)) + if ( (Printer->printer_type == PRINTER_HANDLE_IS_PRINTER) && !get_printer_snum(p, handle, &snum) ) return WERR_BADFID; Printer->notify.flags=flags; -- cgit From 4be3750d8e5edb849cf946def10891e0d4dd16d0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 9 Nov 2002 14:48:27 +0000 Subject: deldriver fix (This used to be commit f20de1f9b0dcac15fbf968e6d5d5af2fdd5fbda1) --- source3/include/nt_status.h | 1 + source3/rpc_server/srv_spoolss_nt.c | 6 ++++++ source3/rpcclient/cmd_spoolss.c | 17 +++++++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/source3/include/nt_status.h b/source3/include/nt_status.h index 1c80c5ecde..9747f73eb1 100644 --- a/source3/include/nt_status.h +++ b/source3/include/nt_status.h @@ -58,5 +58,6 @@ typedef uint32 WERROR; #define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000) #define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y)) #define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0) +#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y)) #endif diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 5ebefc5ea0..f8262110ce 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1908,6 +1908,12 @@ WERROR _spoolss_deleteprinterdriver(pipes_struct *p, SPOOL_Q_DELETEPRINTERDRIVER goto done; } } + /* otherwise it was a failure */ + else { + status = WERR_UNKNOWN_PRINTER_DRIVER; + goto done; + } + } if (printer_driver_in_use(info.info_3)) { diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 4b5c6676e8..83096a3632 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1259,16 +1259,21 @@ static NTSTATUS cmd_spoolss_deletedriver(struct cli_state *cli, result = cli_spoolss_deleteprinterdriver( cli, mem_ctx, archi_table[i].long_archi, argv[1]); - if (!W_ERROR_IS_OK(result)) { - printf ("Failed to remove driver %s for arch [%s] - error 0x%x!\n", - argv[1], archi_table[i].long_archi, - W_ERROR_V(result)); - } else + if ( !W_ERROR_IS_OK(result) ) { + if ( !W_ERROR_EQUAL(result, WERR_UNKNOWN_PRINTER_DRIVER) ) { + printf ("Failed to remove driver %s for arch [%s] - error 0x%x!\n", + argv[1], archi_table[i].long_archi, + W_ERROR_V(result)); + } + } + else + { printf ("Driver %s removed for arch [%s].\n", argv[1], archi_table[i].long_archi); + } } - return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; + return W_ERROR_IS_OK(result) || W_ERROR_EQUAL(result, WERR_UNKNOWN_PRINTER_DRIVER) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL; } static NTSTATUS cmd_spoolss_getprintprocdir(struct cli_state *cli, -- cgit From bf89d62259765c23b35a7860b64acc614ce4aaf7 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Sat, 9 Nov 2002 17:59:24 +0000 Subject: Add net help join text, from Steve Langasek. Also update the other commands to his correct example of [], since it is optional. Thanks, Steve. (This used to be commit 9fc12e6cb23aa34b2542252b2a05d8a17b8172ce) --- source3/utils/net_help.c | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c index 262670cb2a..fc0fdd0f09 100644 --- a/source3/utils/net_help.c +++ b/source3/utils/net_help.c @@ -64,12 +64,14 @@ static int help_usage(int argc, const char **argv) int net_help_user(int argc, const char **argv) { - d_printf("\nnet user [misc. options] [targets]\n\tList users\n"); - d_printf("\nnet user DELETE [misc. options] [targets]"\ + d_printf("\nnet [] user [misc. options] [targets]"\ + "\n\tList users\n\n"); + d_printf("net [] user DELETE [misc. options] [targets]"\ "\n\tDelete specified user\n"); - d_printf("\nnet user INFO [misc. options] [targets]"\ + d_printf("\nnet [] user INFO [misc. options] [targets]"\ "\n\tList the domain groups of the specified user\n"); - d_printf("\nnet user ADD [password] [-F user flags] [misc. options]"\ + d_printf("\nnet [] user ADD [password] "\ + "[-F user flags] [misc. options]"\ " [targets]\n\tAdd specified user\n"); net_common_methods_usage(argc, argv); @@ -81,11 +83,12 @@ int net_help_user(int argc, const char **argv) int net_help_group(int argc, const char **argv) { - d_printf("net group [misc. options] [targets]"\ + d_printf("net [] group [misc. options] [targets]"\ "\n\tList user groups\n\n"); - d_printf("net group DELETE [misc. options] [targets]"\ + d_printf("net [] group DELETE "\ + "[misc. options] [targets]"\ "\n\tDelete specified group\n"); - d_printf("\nnet group ADD [-C comment]"\ + d_printf("\nnet [] group ADD [-C comment]"\ " [misc. options] [targets]\n\tCreate specified group\n"); net_common_methods_usage(argc, argv); net_common_flags_usage(argc, argv); @@ -94,15 +97,27 @@ int net_help_group(int argc, const char **argv) return -1; } + +int net_help_join(int argc, const char **argv) +{ + d_printf("\nnet [] join [misc. options]\n" + "\tjoins this server to a domain\n"); + d_printf("Valid methods: (auto-detected if not specified)\n"); + d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n"); + d_printf("\trpc\t\t\t\tDCE-RPC\n"); + net_common_flags_usage(argc, argv); + return -1; +} + int net_help_share(int argc, const char **argv) { d_printf( - "\nnet share [misc. options] [targets] \n" + "\nnet [] share [misc. options] [targets] \n" "\tenumerates all exported resources (network shares) " - "on target server\n" - "\nnet share ADD [misc. options] [targets]" - "\n\tAdds a share from a server (makes the export active)\n" - "\nnet share DELETE [misc. options] [targets]\n" + "on target server\n\n" + "net [] share ADD [misc. options] [targets]" + "\n\tAdds a share from a server (makes the export active)\n\n" + "net [] share DELETE [misc. options] [targets]\n" "\n\tDeletes a share from a server (makes the export inactive)\n"); net_common_methods_usage(argc, argv); net_common_flags_usage(argc, argv); @@ -114,11 +129,12 @@ int net_help_share(int argc, const char **argv) int net_help_file(int argc, const char **argv) { - d_printf("net file [misc. options] [targets]\n"\ + d_printf("net [] file [misc. options] [targets]\n"\ "\tlists all open files on file server\n\n"); - d_printf("net file USER [misc. options] [targets]"\ + d_printf("net [] file USER "\ + "[misc. options] [targets]"\ "\n\tlists all files opened by username on file server\n\n"); - d_printf("net file CLOSE [misc. options] [targets]\n"\ + d_printf("net [] file CLOSE [misc. options] [targets]\n"\ "\tcloses specified file on target server\n\n"); d_printf("net [rap] file INFO [misc. options] [targets]\n"\ "\tdisplays information about the specified open file\n"); @@ -165,6 +181,7 @@ int net_help(int argc, const char **argv) {"PRINTQ", net_rap_printq_usage}, {"USER", net_help_user}, {"GROUP", net_help_group}, + {"JOIN", net_help_join}, {"VALIDATE", net_rap_validate_usage}, {"GROUPMEMBER", net_rap_groupmember_usage}, {"ADMIN", net_rap_admin_usage}, -- cgit From a0dd6128bfb73a3078a2686a1998b7fbd541ca6c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 9 Nov 2002 23:17:01 +0000 Subject: Kill append_log from smbmount (thanks vance for reminding me). Andrew Bartlett (This used to be commit 7501b2a51835bae005d2ac015c3a428eaadce032) --- source3/client/smbmount.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c index 0db990e8bd..a29ab48ece 100644 --- a/source3/client/smbmount.c +++ b/source3/client/smbmount.c @@ -28,7 +28,6 @@ extern BOOL in_client; extern pstring user_socket_options; -extern BOOL append_log; static pstring credentials; static pstring my_netbios_name; @@ -378,7 +377,6 @@ static void send_fs_socket(char *the_service, char *mount_point, struct cli_stat /* here we are no longer interactive */ set_remote_machine_name("smbmount"); /* sneaky ... */ setup_logging("mount.smbfs", False); - append_log = True; reopen_logs(); DEBUG(0, ("mount.smbfs: entering daemon mode for service %s, pid=%d\n", the_service, sys_getpid())); -- cgit From a46d452926cea70bb59ba470cfc5cb2cde88c027 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Nov 2002 00:35:04 +0000 Subject: make sure that if kerberos fails we can fall back on NTLMSSP for SASL (This used to be commit 69dba08c40c9739137b4f01d38be5228edc6dd6e) --- source3/libads/sasl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c index dacf8f7da8..16ad397d0e 100644 --- a/source3/libads/sasl.c +++ b/source3/libads/sasl.c @@ -196,8 +196,11 @@ static ADS_STATUS ads_sasl_spnego_bind(ADS_STRUCT *ads) status = ads_sasl_spnego_krb5_bind(ads, principal); if (ADS_ERR_OK(status)) return status; - if (ads_kinit_password(ads) == 0) - return ads_sasl_spnego_krb5_bind(ads, principal); + if (ads_kinit_password(ads) == 0) { + status = ads_sasl_spnego_krb5_bind(ads, principal); + } + if (ADS_ERR_OK(status)) + return status; } #endif -- cgit From 0026d5fb681d834f8db171b8ceed634b1976ad8f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Nov 2002 02:16:43 +0000 Subject: make sure we don't try to decode any null password buffers during a SAM sync. This copes with both unset passwords from NT4 DCs and the null passwords you get from w2k domains. (This used to be commit 20c1cd86aca8040c1fe7497b84bb546526676e48) --- source3/utils/net_rpc_samsync.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c index 583d50cf4f..34d926ab61 100644 --- a/source3/utils/net_rpc_samsync.c +++ b/source3/utils/net_rpc_samsync.c @@ -56,14 +56,23 @@ static void display_account_info(uint32 rid, SAM_ACCOUNT_INFO *a) { fstring hex_nt_passwd, hex_lm_passwd; uchar lm_passwd[16], nt_passwd[16]; + static uchar zero_buf[16]; - /* Decode hashes from password hash */ - sam_pwd_hash(a->user_rid, a->pass.buf_lm_pwd, lm_passwd, 0); - sam_pwd_hash(a->user_rid, a->pass.buf_nt_pwd, nt_passwd, 0); + /* Decode hashes from password hash (if they are not NULL) */ - /* Encode as strings */ - smbpasswd_sethexpwd(hex_lm_passwd, lm_passwd, a->acb_info); - smbpasswd_sethexpwd(hex_nt_passwd, nt_passwd, a->acb_info); + if (memcmp(a->pass.buf_lm_pwd, zero_buf, 16) != 0) { + sam_pwd_hash(a->user_rid, a->pass.buf_lm_pwd, lm_passwd, 0); + smbpasswd_sethexpwd(hex_lm_passwd, lm_passwd, a->acb_info); + } else { + smbpasswd_sethexpwd(hex_lm_passwd, NULL, 0); + } + + if (memcmp(a->pass.buf_nt_pwd, zero_buf, 16) != 0) { + sam_pwd_hash(a->user_rid, a->pass.buf_nt_pwd, nt_passwd, 0); + smbpasswd_sethexpwd(hex_nt_passwd, nt_passwd, a->acb_info); + } else { + smbpasswd_sethexpwd(hex_nt_passwd, NULL, 0); + } printf("%s:%d:%s:%s:%s:LCT-0\n", unistr2_static(&a->uni_acct_name), a->user_rid, hex_lm_passwd, hex_nt_passwd, @@ -194,6 +203,7 @@ sam_account_from_delta(SAM_ACCOUNT *account, SAM_ACCOUNT_INFO *delta) { fstring s; uchar lm_passwd[16], nt_passwd[16]; + static uchar zero_buf[16]; /* Username, fullname, home dir, dir drive, logon script, acct desc, workstations, profile. */ @@ -246,11 +256,20 @@ sam_account_from_delta(SAM_ACCOUNT *account, SAM_ACCOUNT_INFO *delta) pdb_set_kickoff_time(account, get_time_t_max(), PDB_CHANGED); - /* Decode hashes from password hash */ - sam_pwd_hash(delta->user_rid, delta->pass.buf_lm_pwd, lm_passwd, 0); - sam_pwd_hash(delta->user_rid, delta->pass.buf_nt_pwd, nt_passwd, 0); - pdb_set_nt_passwd(account, nt_passwd, PDB_CHANGED); - pdb_set_lanman_passwd(account, lm_passwd, PDB_CHANGED); + /* 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); + } + + if (memcmp(delta->pass.buf_nt_pwd, zero_buf, 16) != 0) { + sam_pwd_hash(delta->user_rid, delta->pass.buf_nt_pwd, nt_passwd, 0); + pdb_set_nt_passwd(account, nt_passwd, PDB_CHANGED); + } /* TODO: account expiry time */ -- cgit From f4fb10c62282daeefa48e7d91353de442fac27ca Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Sun, 10 Nov 2002 03:00:28 +0000 Subject: Fix for scalable printing noticed by tpot. Don't loop infinately when holding a mutex.... :-). Jeremy. (This used to be commit c206643baaae64cef38f2f74e46337d35a489ca9) --- source3/printing/printing.c | 49 +++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 71e09c793f..9bc4606ada 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1047,7 +1047,7 @@ static void print_queue_update(int snum) #define NOTIFY_PID_LIST_KEY "NOTIFY_PID_LIST" -static TDB_DATA get_printer_notify_pid_list(struct tdb_print_db *pdb) +static TDB_DATA get_printer_notify_pid_list(struct tdb_print_db *pdb, BOOL cleanlist) { TDB_DATA data; size_t i; @@ -1062,18 +1062,21 @@ static TDB_DATA get_printer_notify_pid_list(struct tdb_print_db *pdb) } if (data.dsize % 8) { - DEBUG(0,("get_pid_list: Size of record for printer %s not a multiple of 8 !\n", + DEBUG(0,("get_printer_notify_pid_list: Size of record for printer %s not a multiple of 8 !\n", pdb->printer_name )); tdb_delete_by_string(pdb->tdb, NOTIFY_PID_LIST_KEY ); ZERO_STRUCT(data); return data; } + if (!cleanlist) + return data; + /* * Weed out all dead entries. */ - for( i = 0; i < data.dsize; ) { + for( i = 0; i < data.dsize; i += 8) { pid_t pid = (pid_t)IVAL(data.dptr, i); if (pid == sys_getpid()) @@ -1081,21 +1084,18 @@ static TDB_DATA get_printer_notify_pid_list(struct tdb_print_db *pdb) /* Entry is dead if process doesn't exist or refcount is zero. */ - if ((IVAL(data.dptr, i + 4) == 0) || !process_exists(pid)) { + while ((i < data.dsize) && ((IVAL(data.dptr, i + 4) == 0) || !process_exists(pid))) { /* Refcount == zero is a logic error and should never happen. */ if (IVAL(data.dptr, i + 4) == 0) { - DEBUG(0,("get_pid_list: Refcount == 0 for pid = %u printer %s !\n", + DEBUG(0,("get_printer_notify_pid_list: Refcount == 0 for pid = %u printer %s !\n", (unsigned int)pid, pdb->printer_name )); } if (data.dsize - i > 8) memmove( &data.dptr[i], &data.dptr[i+8], data.dsize - i - 8); data.dsize -= 8; - continue; } - - i += 8; } return data; @@ -1121,13 +1121,13 @@ BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t if (!pdb) return False; - if (tdb_lock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY, 10) == -1) { + if (tdb_read_lock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY, 10) == -1) { DEBUG(0,("print_notify_pid_list: Failed to lock printer %s database\n", printername)); release_print_db(pdb); return False; } - data = get_printer_notify_pid_list( pdb ); + data = get_printer_notify_pid_list( pdb, True ); if (!data.dptr) { ret = True; @@ -1151,7 +1151,7 @@ BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t done: - tdb_unlock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY); + tdb_read_unlock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY); release_print_db(pdb); SAFE_FREE(data.dptr); return ret; @@ -1181,7 +1181,7 @@ BOOL print_notify_register_pid(int snum) return False; } - data = get_printer_notify_pid_list( pdb ); + data = get_printer_notify_pid_list( pdb, True ); /* Add ourselves and increase the refcount. */ @@ -1245,7 +1245,7 @@ BOOL print_notify_deregister_pid(int snum) return False; } - data = get_printer_notify_pid_list( pdb ); + data = get_printer_notify_pid_list( pdb, True ); /* Reduce refcount. Remove ourselves if zero. */ @@ -1454,6 +1454,14 @@ BOOL print_job_delete(struct current_user *user, int snum, uint32 jobid, WERROR !print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) { DEBUG(3, ("delete denied by security descriptor\n")); *errcode = WERR_ACCESS_DENIED; + + /* BEGIN_ADMIN_LOG */ + sys_adminlog( LOG_ERR, (char *) + "Permission denied-- user not allowed to delete, \ +pause, or resume print job. User name: %s. Printer name: %s.", + uidtoname(user->uid), PRINTERNAME(snum) ); + /* END_ADMIN_LOG */ + return False; } @@ -1511,6 +1519,14 @@ BOOL print_job_pause(struct current_user *user, int snum, uint32 jobid, WERROR * if (!is_owner(user, snum, jobid) && !print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) { DEBUG(3, ("pause denied by security descriptor\n")); + + /* BEGIN_ADMIN_LOG */ + sys_adminlog( LOG_ERR, (char *) + "Permission denied-- user not allowed to delete, \ +pause, or resume print job. User name: %s. Printer name: %s.", + uidtoname(user->uid), PRINTERNAME(snum) ); + /* END_ADMIN_LOG */ + *errcode = WERR_ACCESS_DENIED; return False; } @@ -1554,6 +1570,13 @@ BOOL print_job_resume(struct current_user *user, int snum, uint32 jobid, WERROR !print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) { DEBUG(3, ("resume denied by security descriptor\n")); *errcode = WERR_ACCESS_DENIED; + + /* BEGIN_ADMIN_LOG */ + sys_adminlog( LOG_ERR, (char *) + "Permission denied-- user not allowed to delete, \ +pause, or resume print job. User name: %s. Printer name: %s.", + uidtoname(user->uid), PRINTERNAME(snum) ); + /* END_ADMIN_LOG */ return False; } -- cgit From 10968f47cf413d5471c7ca63394b376eac9eef40 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 10 Nov 2002 04:16:59 +0000 Subject: consolidate error mapping functions into a single file (This used to be commit 80086728f2b0d5d56a8ed9e427cba36898d68fc7) --- source3/Makefile.in | 2 +- source3/lib/error.c | 75 ----------------------------------------------- source3/libsmb/errormap.c | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 76 deletions(-) delete mode 100644 source3/lib/error.c diff --git a/source3/Makefile.in b/source3/Makefile.in index 8d0add9b7a..94920a6e75 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -135,7 +135,7 @@ LIB_OBJ = lib/charcnv.o lib/debug.o lib/fault.o \ lib/util_unistr.o lib/util_file.o lib/data_blob.o \ lib/util.o lib/util_sock.o lib/util_sec.o \ lib/talloc.o lib/hash.o lib/substitute.o lib/fsusage.o \ - lib/ms_fnmatch.o lib/select.o lib/error.o lib/messages.o \ + lib/ms_fnmatch.o lib/select.o lib/messages.o \ lib/tallocmsg.o lib/dmallocmsg.o \ lib/md5.o lib/hmacmd5.o lib/iconv.o lib/smbpasswd.o \ nsswitch/wb_client.o nsswitch/wb_common.o \ diff --git a/source3/lib/error.c b/source3/lib/error.c deleted file mode 100644 index af8cf960e8..0000000000 --- a/source3/lib/error.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * Unix/DOS/NT error code conversions - * Copyright (C) Tim Potter 2000 - * - * 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" - -/* Mapping between Unix, DOS and NT error numbers */ - -const struct unix_error_map unix_dos_nt_errmap[] = { - { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, - { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, - { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, - { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, - { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, - { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, - { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, - { ENFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, - { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, - { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, -#ifdef EDQUOT - { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, -#endif -#ifdef ENOTEMPTY - { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY }, -#endif -#ifdef EXDEV - { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, -#endif -#ifdef EROFS - { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, -#endif -#ifdef ENAMETOOLONG - { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID }, -#endif - { 0, 0, 0, NT_STATUS_OK } -}; - -/********************************************************************* - Map an NT error code from a Unix error code. -*********************************************************************/ - -NTSTATUS map_nt_error_from_unix(int unix_error) -{ - int i = 0; - - if (unix_error == 0) - return NT_STATUS_OK; - - /* Look through list */ - while(unix_dos_nt_errmap[i].unix_error != 0) { - if (unix_dos_nt_errmap[i].unix_error == unix_error) - return unix_dos_nt_errmap[i].nt_error; - i++; - } - - /* Default return */ - return NT_STATUS_ACCESS_DENIED; -} diff --git a/source3/libsmb/errormap.c b/source3/libsmb/errormap.c index a35108c3de..7c28c7e8aa 100644 --- a/source3/libsmb/errormap.c +++ b/source3/libsmb/errormap.c @@ -3,6 +3,7 @@ * error mapping functions * Copyright (C) Andrew Tridgell 2001 * Copyright (C) Andrew Bartlett 2001 + * Copyright (C) Tim Potter 2000 * * 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 @@ -1482,3 +1483,57 @@ WERROR ntstatus_to_werror(NTSTATUS error) /* a lame guess */ return W_ERROR(NT_STATUS_V(error) & 0xffff); } + +/* Mapping between Unix, DOS and NT error numbers */ + +const struct unix_error_map unix_dos_nt_errmap[] = { + { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, + { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED }, + { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND }, + { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR }, + { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, + { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE }, + { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION}, + { ENFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, + { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES }, + { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, +#ifdef EDQUOT + { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, +#endif +#ifdef ENOTEMPTY + { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY }, +#endif +#ifdef EXDEV + { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE }, +#endif +#ifdef EROFS + { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED }, +#endif +#ifdef ENAMETOOLONG + { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID }, +#endif + { 0, 0, 0, NT_STATUS_OK } +}; + +/********************************************************************* + Map an NT error code from a Unix error code. +*********************************************************************/ + +NTSTATUS map_nt_error_from_unix(int unix_error) +{ + int i = 0; + + if (unix_error == 0) + return NT_STATUS_OK; + + /* Look through list */ + while(unix_dos_nt_errmap[i].unix_error != 0) { + if (unix_dos_nt_errmap[i].unix_error == unix_error) + return unix_dos_nt_errmap[i].nt_error; + i++; + } + + /* Default return */ + return NT_STATUS_ACCESS_DENIED; +} -- cgit From c9bd108a81c2419ae5a5750d3eb1c253a7294fd9 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 10 Nov 2002 12:07:54 +0000 Subject: Add example for MySQL (This used to be commit de136d294fce59bdc4d0a65d35071c2837ef92a5) --- examples/pdb/mysql/mysql.dump | 35 +++++++++++++++++++++++++++++++++++ examples/pdb/mysql/smb.conf | 11 +++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/pdb/mysql/mysql.dump create mode 100644 examples/pdb/mysql/smb.conf diff --git a/examples/pdb/mysql/mysql.dump b/examples/pdb/mysql/mysql.dump new file mode 100644 index 0000000000..12eac6cdc7 --- /dev/null +++ b/examples/pdb/mysql/mysql.dump @@ -0,0 +1,35 @@ +# Put this in your MySQL database by running +# mysql -u -p -h < mysql.dump + +CREATE TABEL user ( + logon_time int(9), + logoff_time int(9), + kickoff_time int(9), + pass_last_set_time int(9), + pass_can_change_time int(9), + pass_must_change_time int(9), + username varchar(255), + domain varchar(255), + nt_username varchar(255), + nt_fullname varchar(255), + home_dir varchar(255), + dir_drive varchar(4), + logon_script varchar(255), + profile_path varchar(255), + acct_desc varchar(255), + workstations varchar(255), + unknown_str varchar(255), + munged_dial varchar(255), + uid int(9) NOT NULL DEFAULT "0" PRIMARY KEY auto_increment, + gid int(9), + user_sid varchar(255), + group_sid varchar(255), + lm_pw varchar(255), + nt_pw varchar(255), + acct_ctrl int(9), + unknown_3 int(9), + logon_divs int(9), + hours_len int(9), + unknown_5 int(9), + unknown_6 int(9) +); diff --git a/examples/pdb/mysql/smb.conf b/examples/pdb/mysql/smb.conf new file mode 100644 index 0000000000..61a3f19816 --- /dev/null +++ b/examples/pdb/mysql/smb.conf @@ -0,0 +1,11 @@ +[global] +netbios name = FOOBAR +workgroup = TESTGROUP +security = domain +domain logons = yes +domain master = yes +passdb backend = plugin:/usr/local/samba/lib/pdb_mysql.so:mysql +mysql:mysql host = rhonwyn +mysql:mysql user = samba +mysql:mysql password = ambas +mysql:mysql database = samba -- cgit