From 8bf57cf8f57be28831023c2218d358b24b705256 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 2 May 2005 14:17:19 +0000 Subject: r6573: Start on my project to implement an NT4 compatible BDC in Samba4. This brings in a compatability layer for Samba3 in Samba4 - where we will start to define file formats and similar details. The 'net samdump' command uses 'password server = ' for now, and performs a similar task to Samba3's 'net rpc samsync'. Andrew Bartlett (This used to be commit 550f17f9924fe783917318753de7d1a388423908) --- source4/lib/samba3/smbpasswd.c | 208 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 source4/lib/samba3/smbpasswd.c (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c new file mode 100644 index 0000000000..587d038a3d --- /dev/null +++ b/source4/lib/samba3/smbpasswd.c @@ -0,0 +1,208 @@ +/* + Unix SMB/CIFS implementation. + smbpasswd file format routines + + Copyright (C) Andrew Tridgell 1992-1998 + Modified by Jeremy Allison 1995. + Modified by Gerald (Jerry) Carter 2000-2001 + Copyright (C) Tim Potter 2001 + Copyright (C) Andrew Bartlett 2005 + + 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. +*/ + +/*! \file lib/smbpasswd.c + + The smbpasswd file is used to store encrypted passwords in a similar + fashion to the /etc/passwd file. The format is colon separated fields + with one user per line like so: + + ::::: + + The username and uid must correspond to an entry in the /etc/passwd + file. The lanman and nt password hashes are 32 hex digits corresponding + to the 16-byte lanman and nt hashes respectively. + + The password last change time is stored as a string of the format + LCD- where the change time is expressed as an + + 'N' No password + 'D' Disabled + 'H' Homedir required + 'T' Temp account. + 'U' User account (normal) + 'M' MNS logon user account - what is this ? + 'W' Workstation account + 'S' Server account + 'L' Locked account + 'X' No Xpiry on password + 'I' Interdomain trust account + +*/ + +#include "includes.h" +#include "librpc/gen_ndr/ndr_samr.h" +#include "system/iconv.h" + +/*! Convert 32 hex characters into a 16 byte array. */ + +struct samr_Password *smbpasswd_gethexpwd(TALLOC_CTX *mem_ctx, char *p) +{ + int i; + unsigned char lonybble, hinybble; + const char *hexchars = "0123456789ABCDEF"; + char *p1, *p2; + struct samr_Password *pwd = talloc(mem_ctx, struct samr_Password); + + if (!p) return NULL; + + for (i = 0; i < (sizeof(pwd->hash) * 2); i += 2) + { + hinybble = toupper(p[i]); + lonybble = toupper(p[i + 1]); + + p1 = strchr_m(hexchars, hinybble); + p2 = strchr_m(hexchars, lonybble); + + if (!p1 || !p2) + { + return (False); + } + + hinybble = PTR_DIFF(p1, hexchars); + lonybble = PTR_DIFF(p2, hexchars); + + pwd->hash[i / 2] = (hinybble << 4) | lonybble; + } + return pwd; +} + +/*! Convert a 16-byte array into 32 hex characters. */ + struct samr_Password *lm_hash_p = NULL; + struct samr_Password *nt_hash_p = NULL; + +char *smbpasswd_sethexpwd(TALLOC_CTX *mem_ctx, struct samr_Password *pwd, uint16_t acb_info) +{ + char *p; + if (pwd != NULL) { + int i; + p = talloc_array(mem_ctx, char, 33); + if (!p) { + return NULL; + } + + for (i = 0; i < sizeof(pwd->hash); i++) + slprintf(&p[i*2], 3, "%02X", pwd->hash[i]); + } else { + if (acb_info & ACB_PWNOTREQ) + p = talloc_strdup(mem_ctx, "NO PASSWORDXXXXXXXXXXXXXXXXXXXXX"); + else + p = talloc_strdup(mem_ctx, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); + } + return p; +} + +/*! Decode the account control bits (ACB) info from a string. */ + +uint16_t smbpasswd_decode_acb_info(const char *p) +{ + uint16_t acb_info = 0; + BOOL finished = False; + + /* + * Check if the account type bits have been encoded after the + * NT password (in the form [NDHTUWSLXI]). + */ + + if (*p != '[') return 0; + + for (p++; *p && !finished; p++) + { + switch (*p) { + case 'N': /* 'N'o password. */ + acb_info |= ACB_PWNOTREQ; + break; + case 'D': /* 'D'isabled. */ + acb_info |= ACB_DISABLED; + break; + case 'H': /* 'H'omedir required. */ + acb_info |= ACB_HOMDIRREQ; + break; + case 'T': /* 'T'emp account. */ + acb_info |= ACB_TEMPDUP; + break; + case 'U': /* 'U'ser account (normal). */ + acb_info |= ACB_NORMAL; + break; + case 'M': /* 'M'NS logon user account. What is this ? */ + acb_info |= ACB_MNS; + break; + case 'W': /* 'W'orkstation account. */ + acb_info |= ACB_WSTRUST; + break; + case 'S': /* 'S'erver account. */ + acb_info |= ACB_SVRTRUST; + break; + case 'L': /* 'L'ocked account. */ + acb_info |= ACB_AUTOLOCK; + break; + case 'X': /* No 'X'piry on password */ + acb_info |= ACB_PWNOEXP; + break; + case 'I': /* 'I'nterdomain trust account. */ + acb_info |= ACB_DOMTRUST; + break; + + case ' ': + break; + case ':': + case '\n': + case '\0': + case ']': + default: + finished = True; + break; + } + } + + return acb_info; +} + +/*! Encode account control bits (ACBs) into a string. */ + +char *smbpasswd_encode_acb_info(TALLOC_CTX *mem_ctx, uint16_t acb_info) +{ + char *acct_str = talloc_array(mem_ctx, char, 35); + size_t i = 0; + + acct_str[i++] = '['; + + if (acb_info & ACB_PWNOTREQ ) acct_str[i++] = 'N'; + if (acb_info & ACB_DISABLED ) acct_str[i++] = 'D'; + if (acb_info & ACB_HOMDIRREQ) acct_str[i++] = 'H'; + if (acb_info & ACB_TEMPDUP ) acct_str[i++] = 'T'; + if (acb_info & ACB_NORMAL ) acct_str[i++] = 'U'; + if (acb_info & ACB_MNS ) acct_str[i++] = 'M'; + if (acb_info & ACB_WSTRUST ) acct_str[i++] = 'W'; + if (acb_info & ACB_SVRTRUST ) acct_str[i++] = 'S'; + if (acb_info & ACB_AUTOLOCK ) acct_str[i++] = 'L'; + if (acb_info & ACB_PWNOEXP ) acct_str[i++] = 'X'; + if (acb_info & ACB_DOMTRUST ) acct_str[i++] = 'I'; + + acct_str[i++] = ']'; + acct_str[i++] = '\0'; + + return acct_str; +} -- cgit From 3191ed9ae97f7cb6da9dd1034ec416e6e892150a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 9 Jul 2005 01:53:01 +0000 Subject: r8245: Add const. Andrew Bartlett (This used to be commit 8c079ce1631433f6bf1da8f378ea5f1a271a02ae) --- source4/lib/samba3/smbpasswd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index 587d038a3d..bcbb5e56d8 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -58,12 +58,12 @@ /*! Convert 32 hex characters into a 16 byte array. */ -struct samr_Password *smbpasswd_gethexpwd(TALLOC_CTX *mem_ctx, char *p) +struct samr_Password *smbpasswd_gethexpwd(TALLOC_CTX *mem_ctx, const char *p) { int i; unsigned char lonybble, hinybble; const char *hexchars = "0123456789ABCDEF"; - char *p1, *p2; + const char *p1, *p2; struct samr_Password *pwd = talloc(mem_ctx, struct samr_Password); if (!p) return NULL; -- cgit From ec934124db8a5234d8c83799a23c7bdced5dd95a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 29 Aug 2005 22:01:18 +0000 Subject: r9762: Add support for reading good old smbpasswd files Fix password support Make base64 decode/encode functions available to EJS (This used to be commit 1376a1fe44cd6b01709819095a711c14626b1d3e) --- source4/lib/samba3/smbpasswd.c | 132 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index bcbb5e56d8..5976d2db57 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -7,6 +7,7 @@ Modified by Gerald (Jerry) Carter 2000-2001 Copyright (C) Tim Potter 2001 Copyright (C) Andrew Bartlett 2005 + Copyright (C) Jelmer Vernooij 2005 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,6 +55,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_samr.h" +#include "lib/samba3/samba3.h" #include "system/iconv.h" /*! Convert 32 hex characters into a 16 byte array. */ @@ -206,3 +208,133 @@ char *smbpasswd_encode_acb_info(TALLOC_CTX *mem_ctx, uint16_t acb_info) return acct_str; } + +NTSTATUS samba3_read_smbpasswd(const char *filename, TALLOC_CTX *ctx, struct samba3_samaccount **accounts, uint32_t *count) +{ + int numlines; + char **lines; + *count = 0; + *accounts = NULL; + int i; + + lines = file_lines_load(filename, &numlines, ctx); + + *accounts = talloc_array(ctx, struct samba3_samaccount, numlines); + + for (i = 0; i < numlines; i++) { + char *p = lines[i], *q; + struct samba3_samaccount *acc = &((*accounts)[*count]); + + if (p[0] == '\0' || p[0] == '#') + continue; + + ZERO_STRUCTP(acc); + + q = strchr(p, ':'); + if (!q) { + DEBUG(0, ("%s:%d: expected ':'\n", filename, i)); + continue; + } + + acc->username = talloc_strndup(ctx, p, PTR_DIFF(q, p)); + p = q+1; + + acc->uid = atoi(p); + + q = strchr(p, ':'); + if (!q) { + DEBUG(0, ("%s:%d: expected ':'\n", filename, i)); + continue; + } + p = q+1; + + if (strlen(p) < 33) { + DEBUG(0, ("%s:%d: expected 32 byte password blob\n", filename, i)); + continue; + } + + if (!strncmp(p, "NO PASSWORD", strlen("NO PASSWORD"))) { + acc->acct_ctrl |= ACB_PWNOTREQ; + } else if (p[0] == '*' || p[0] == 'X') { + /* No password set */ + } else { + struct samr_Password *pw = smbpasswd_gethexpwd(*accounts, p); + + if (!pw) { + DEBUG(0, ("%s:%d: Malformed LM pw entry\n", filename, i)); + continue; + } + + memcpy(acc->lm_pw.hash, pw, sizeof(*pw)); + } + + if (p[32] != ':') { + DEBUG(0, ("%s:%d: expected ':' after 32 byte password blob\n", filename, i)); + continue; + } + + p += 33; + + if (p[0] == '*' || p[0] == 'X') { + /* No password set */ + } else { + struct samr_Password *pw = smbpasswd_gethexpwd(*accounts, p); + + if (!pw) { + DEBUG(0, ("%s:%d: Malformed LM pw entry\n", filename, i)); + continue; + } + + memcpy(acc->nt_pw.hash, pw, sizeof(*pw)); + } + + if (p[32] != ':') { + DEBUG(0, ("%s:%d: expected ':' after 32 byte password blob\n", filename, i)); + continue; + } + + p += 33; + + if (p[0] == '[') { + q = strchr(p, ']'); + if (!q) { + DEBUG(0, ("%s:%d: expected ']'\n", filename, i)); + continue; + } + + acc->acct_ctrl |= smbpasswd_decode_acb_info(p); + + p = q+1; + if (p[0] == ':' && strncmp(p, "LCT-", 4) == 0) { + int j; + p += 4; + + for(j = 0; j < 8; j++) { + if(p[j] == '\0' || !isxdigit(p[j])) { + break; + } + } + if(i == 8) { + acc->pass_last_set_time = (time_t)strtol((char *)p, NULL, 16); + } + } + } else { + /* 'Old' style file. Fake up based on user name. */ + /* + * Currently trust accounts are kept in the same + * password file as 'normal accounts'. If this changes + * we will have to fix this code. JRA. + */ + if(acc->username[strlen(acc->username) - 1] == '$') { + acc->acct_ctrl &= ~ACB_NORMAL; + acc->acct_ctrl |= ACB_WSTRUST; + } + } + + (*count)++; + } + + talloc_free(lines); + + return NT_STATUS_OK; +} -- cgit From 34305d74e19e09d304db4bfe7fcd46504831feaf Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 30 Aug 2005 17:23:07 +0000 Subject: r9808: Improve code that selects what "passdb backend" to import from. (This used to be commit 7739d092d5ca99bd44a1612cc783e38a2f09a67f) --- source4/lib/samba3/smbpasswd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index 5976d2db57..fe0780c8d3 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -219,6 +219,11 @@ NTSTATUS samba3_read_smbpasswd(const char *filename, TALLOC_CTX *ctx, struct sam lines = file_lines_load(filename, &numlines, ctx); + if (lines == NULL) { + DEBUG(0, ("Unable to load lines from %s\n", filename)); + return NT_STATUS_UNSUCCESSFUL; + } + *accounts = talloc_array(ctx, struct samba3_samaccount, numlines); for (i = 0; i < numlines; i++) { -- cgit From 05db3024ba6a8cd0b3182595f4f6f2f1f0987e44 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 1 Sep 2005 00:37:52 +0000 Subject: r9854: Finish ldb_map testsuite Update PLAN Some more small other fixes (This used to be commit de2bde2526ffaf521253e3b9e58fc11417986321) --- source4/lib/samba3/smbpasswd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index fe0780c8d3..baddb82545 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -228,6 +228,7 @@ NTSTATUS samba3_read_smbpasswd(const char *filename, TALLOC_CTX *ctx, struct sam for (i = 0; i < numlines; i++) { char *p = lines[i], *q; + uid_t uid; struct samba3_samaccount *acc = &((*accounts)[*count]); if (p[0] == '\0' || p[0] == '#') @@ -244,7 +245,9 @@ NTSTATUS samba3_read_smbpasswd(const char *filename, TALLOC_CTX *ctx, struct sam acc->username = talloc_strndup(ctx, p, PTR_DIFF(q, p)); p = q+1; - acc->uid = atoi(p); + uid = atoi(p); + + /* uid is ignored here.. */ q = strchr(p, ':'); if (!q) { -- cgit From eb133639dc524cd03f2dd2ba24cf48cd673642f5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 1 Sep 2005 09:14:35 +0000 Subject: r9885: Fix code before declarations. (This used to be commit b7d982c94be05d357a4c3517afc60c7929fb4615) --- source4/lib/samba3/smbpasswd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index baddb82545..483fbcfe05 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -213,9 +213,10 @@ NTSTATUS samba3_read_smbpasswd(const char *filename, TALLOC_CTX *ctx, struct sam { int numlines; char **lines; + int i; + *count = 0; *accounts = NULL; - int i; lines = file_lines_load(filename, &numlines, ctx); -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/lib/samba3/smbpasswd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index 483fbcfe05..e6c52966d9 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -54,7 +54,6 @@ */ #include "includes.h" -#include "librpc/gen_ndr/ndr_samr.h" #include "lib/samba3/samba3.h" #include "system/iconv.h" -- cgit From 172a83d72491f90f6191be1040ef8b2e1789bd2e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 May 2006 19:14:12 +0000 Subject: r15573: Fix build of systems that have iconv headers in non-standard locations Split of system/locale.h header from system/iconv.h Previously, iconv wasn't being used on these systems (This used to be commit aa6d66fda69779d1c2948a1aca85dbd5208f1cba) --- source4/lib/samba3/smbpasswd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index e6c52966d9..acba763371 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -54,8 +54,8 @@ */ #include "includes.h" +#include "system/locale.h" #include "lib/samba3/samba3.h" -#include "system/iconv.h" /*! Convert 32 hex characters into a 16 byte array. */ -- cgit From fbb301a72d48c531d6b564d87b23e6bf384fd13e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 10 Sep 2006 10:30:10 +0000 Subject: r18323: this function returns a pointer, not a bool (This used to be commit 86ef345cbf98e38b4e135cf52761c7268b608313) --- source4/lib/samba3/smbpasswd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index acba763371..c19e90219f 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -77,9 +77,8 @@ struct samr_Password *smbpasswd_gethexpwd(TALLOC_CTX *mem_ctx, const char *p) p1 = strchr_m(hexchars, hinybble); p2 = strchr_m(hexchars, lonybble); - if (!p1 || !p2) - { - return (False); + if (!p1 || !p2) { + return NULL; } hinybble = PTR_DIFF(p1, hexchars); -- cgit From 6f733591330818fd3f7b79806098548fe7de650e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 12 Dec 2006 21:47:47 +0000 Subject: r20134: The IBM Checker correctly notes that *p cannot be \0 and still satisfy the loop entry condition. Andrew Bartlett (This used to be commit c1182751313290fc38af5b1c44bc66b5d1654977) --- source4/lib/samba3/smbpasswd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index c19e90219f..14715a89f7 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -169,7 +169,6 @@ uint16_t smbpasswd_decode_acb_info(const char *p) break; case ':': case '\n': - case '\0': case ']': default: finished = True; -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/lib/samba3/smbpasswd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index 14715a89f7..b7961cde11 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -11,7 +11,7 @@ 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 + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -20,8 +20,7 @@ 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. + along with this program. If not, see . */ /*! \file lib/smbpasswd.c -- cgit From 61ffa08f4c95e29d301de9fbabd6e71c2dbc1056 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 27 Aug 2007 18:10:19 +0000 Subject: r24712: No longer expose the 'BOOL' data type in any interfaces. (This used to be commit 1ce32673d960c8b05b6c1b1b99e1976a402417ae) --- source4/lib/samba3/smbpasswd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index b7961cde11..39e2448b98 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -118,7 +118,7 @@ char *smbpasswd_sethexpwd(TALLOC_CTX *mem_ctx, struct samr_Password *pwd, uint16 uint16_t smbpasswd_decode_acb_info(const char *p) { uint16_t acb_info = 0; - BOOL finished = False; + bool finished = false; /* * Check if the account type bits have been encoded after the @@ -170,7 +170,7 @@ uint16_t smbpasswd_decode_acb_info(const char *p) case '\n': case ']': default: - finished = True; + finished = true; break; } } -- cgit From 4a603898c54d414dfcc14edb7daf5c5582f56e8c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 11 Feb 2008 14:53:28 +0100 Subject: Remove unused function. (This used to be commit e779cf4724610b5d737102d1f55d1367744b188a) --- source4/lib/samba3/smbpasswd.c | 139 ----------------------------------------- 1 file changed, 139 deletions(-) (limited to 'source4/lib/samba3/smbpasswd.c') diff --git a/source4/lib/samba3/smbpasswd.c b/source4/lib/samba3/smbpasswd.c index 39e2448b98..47c826f9df 100644 --- a/source4/lib/samba3/smbpasswd.c +++ b/source4/lib/samba3/smbpasswd.c @@ -204,142 +204,3 @@ char *smbpasswd_encode_acb_info(TALLOC_CTX *mem_ctx, uint16_t acb_info) return acct_str; } - -NTSTATUS samba3_read_smbpasswd(const char *filename, TALLOC_CTX *ctx, struct samba3_samaccount **accounts, uint32_t *count) -{ - int numlines; - char **lines; - int i; - - *count = 0; - *accounts = NULL; - - lines = file_lines_load(filename, &numlines, ctx); - - if (lines == NULL) { - DEBUG(0, ("Unable to load lines from %s\n", filename)); - return NT_STATUS_UNSUCCESSFUL; - } - - *accounts = talloc_array(ctx, struct samba3_samaccount, numlines); - - for (i = 0; i < numlines; i++) { - char *p = lines[i], *q; - uid_t uid; - struct samba3_samaccount *acc = &((*accounts)[*count]); - - if (p[0] == '\0' || p[0] == '#') - continue; - - ZERO_STRUCTP(acc); - - q = strchr(p, ':'); - if (!q) { - DEBUG(0, ("%s:%d: expected ':'\n", filename, i)); - continue; - } - - acc->username = talloc_strndup(ctx, p, PTR_DIFF(q, p)); - p = q+1; - - uid = atoi(p); - - /* uid is ignored here.. */ - - q = strchr(p, ':'); - if (!q) { - DEBUG(0, ("%s:%d: expected ':'\n", filename, i)); - continue; - } - p = q+1; - - if (strlen(p) < 33) { - DEBUG(0, ("%s:%d: expected 32 byte password blob\n", filename, i)); - continue; - } - - if (!strncmp(p, "NO PASSWORD", strlen("NO PASSWORD"))) { - acc->acct_ctrl |= ACB_PWNOTREQ; - } else if (p[0] == '*' || p[0] == 'X') { - /* No password set */ - } else { - struct samr_Password *pw = smbpasswd_gethexpwd(*accounts, p); - - if (!pw) { - DEBUG(0, ("%s:%d: Malformed LM pw entry\n", filename, i)); - continue; - } - - memcpy(acc->lm_pw.hash, pw, sizeof(*pw)); - } - - if (p[32] != ':') { - DEBUG(0, ("%s:%d: expected ':' after 32 byte password blob\n", filename, i)); - continue; - } - - p += 33; - - if (p[0] == '*' || p[0] == 'X') { - /* No password set */ - } else { - struct samr_Password *pw = smbpasswd_gethexpwd(*accounts, p); - - if (!pw) { - DEBUG(0, ("%s:%d: Malformed LM pw entry\n", filename, i)); - continue; - } - - memcpy(acc->nt_pw.hash, pw, sizeof(*pw)); - } - - if (p[32] != ':') { - DEBUG(0, ("%s:%d: expected ':' after 32 byte password blob\n", filename, i)); - continue; - } - - p += 33; - - if (p[0] == '[') { - q = strchr(p, ']'); - if (!q) { - DEBUG(0, ("%s:%d: expected ']'\n", filename, i)); - continue; - } - - acc->acct_ctrl |= smbpasswd_decode_acb_info(p); - - p = q+1; - if (p[0] == ':' && strncmp(p, "LCT-", 4) == 0) { - int j; - p += 4; - - for(j = 0; j < 8; j++) { - if(p[j] == '\0' || !isxdigit(p[j])) { - break; - } - } - if(i == 8) { - acc->pass_last_set_time = (time_t)strtol((char *)p, NULL, 16); - } - } - } else { - /* 'Old' style file. Fake up based on user name. */ - /* - * Currently trust accounts are kept in the same - * password file as 'normal accounts'. If this changes - * we will have to fix this code. JRA. - */ - if(acc->username[strlen(acc->username) - 1] == '$') { - acc->acct_ctrl &= ~ACB_NORMAL; - acc->acct_ctrl |= ACB_WSTRUST; - } - } - - (*count)++; - } - - talloc_free(lines); - - return NT_STATUS_OK; -} -- cgit