summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-06-15 12:14:45 +0000
committerGerald Carter <jerry@samba.org>2006-06-15 12:14:45 +0000
commit7e6fe8e3d3bb8398173778632366303d7ecef37e (patch)
tree4b927e24d293628874d407d2a8f36d90247c7a4a
parentad586149c6ede551f62d3511eba5ab025df1ccbf (diff)
downloadsamba-7e6fe8e3d3bb8398173778632366303d7ecef37e.tar.gz
r16254: pulling klocwork fixes for 3.0.23rc3 (current up to r16251)
-rw-r--r--WHATSNEW.txt26
-rw-r--r--source/auth/auth_sam.c25
-rw-r--r--source/auth/auth_util.c49
-rw-r--r--source/auth/pass_check.c10
-rw-r--r--source/client/client.c34
-rw-r--r--source/client/clitar.c2
-rw-r--r--source/client/smbctool.c30
-rw-r--r--source/lib/getsmbpass.c6
-rw-r--r--source/lib/replace.c101
-rw-r--r--source/lib/time.c38
-rw-r--r--source/libads/ads_struct.c22
-rw-r--r--source/libads/krb5_setpw.c4
-rw-r--r--source/libsmb/asn1.c23
-rw-r--r--source/libsmb/clidfs.c2
-rw-r--r--source/nmbd/nmbd_become_dmb.c10
-rw-r--r--source/nmbd/nmbd_namelistdb.c20
-rw-r--r--source/nmbd/nmbd_subnetdb.c8
-rw-r--r--source/nmbd/nmbd_winsserver.c6
-rw-r--r--source/nsswitch/winbindd_cache.c57
-rw-r--r--source/nsswitch/winbindd_rpc.c2
-rw-r--r--source/pam_smbpass/pam_smb_acct.c140
-rw-r--r--source/pam_smbpass/pam_smb_auth.c160
-rw-r--r--source/passdb/passdb.c41
-rw-r--r--source/passdb/pdb_get_set.c327
-rw-r--r--source/passdb/pdb_interface.c259
-rw-r--r--source/passdb/secrets.c5
-rw-r--r--source/printing/lpq_parse.c1402
-rw-r--r--source/printing/printing.c39
-rw-r--r--source/rpc_server/srv_netlog_nt.c24
-rw-r--r--source/smbd/chgpasswd.c5
-rw-r--r--source/smbd/lanman.c14
-rw-r--r--source/smbd/msdfs.c3
-rw-r--r--source/smbd/open.c3
-rw-r--r--source/smbd/trans2.c4
-rw-r--r--source/utils/net_cache.c26
-rw-r--r--source/utils/net_status.c4
-rw-r--r--source/utils/net_time.c5
-rw-r--r--source/utils/net_usershare.c2
-rw-r--r--source/utils/ntlm_auth_diagnostics.c2
-rw-r--r--source/utils/smbpasswd.c33
-rw-r--r--source/utils/status.c4
-rw-r--r--source/web/statuspage.c2
42 files changed, 1498 insertions, 1481 deletions
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 51b6169fb6e..9ef2c133e74 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -8,6 +8,11 @@ provided for testing purposes only. While close to the final stable
release, this snapshot is *not* intended for production servers.
Your testing and feedback is greatly appreciated.
+We would like to thank the developers of Klocwork for their analysis
+of the Samba source tree. This release candidate includes fixes
+for over two dozen defects reported by the Klocwork code analyzer.
+
+
Common issues addressed in 3.0.23rc3 include:
o
@@ -22,10 +27,31 @@ Changes since 3.0.23rc2
commits
-------
+o Jeremy Allison <jra@samba.org>
+ * Fixes for various Klocwork defect reports.
+ * Cleanup pdb_get_XXX() methods and ensure that a failure
+ to allocate memory for a samu user structure is reported
+ as a failure to the calling function.
+
+
+o Gerald (Jerry) Carter <jerry@samba.org>
+ * Fix 'make install' problem when building outside source/.
+
+
o Guenther Deschner <gd@samba.org>
* Fix memleaks in winbindd ads searches.
* Fix timestamp bug in pam_winbindd which forced users to change
passwords prematurelty.
+ * Small debug message cleanups.
+
+
+o Volker Lendecke <vl@samba.org>
+ * Fixes for various Klocwork defect reports.
+ * Fixes for two Coverity defect reports.
+
+
+o Jason Mader <jason@ncac.gwu.edu>
+ * Compiler warning fixes.
Release Notes for older release follow:
diff --git a/source/auth/auth_sam.c b/source/auth/auth_sam.c
index 50ce9065fd9..ec405dd2be4 100644
--- a/source/auth/auth_sam.c
+++ b/source/auth/auth_sam.c
@@ -77,6 +77,7 @@ static BOOL logon_hours_ok(struct samu *sampass)
const uint8 *hours;
struct tm *utctime;
time_t lasttime;
+ const char *asct;
uint8 bitmask, bitpos;
hours = pdb_get_hours(sampass);
@@ -87,20 +88,36 @@ static BOOL logon_hours_ok(struct samu *sampass)
lasttime = time(NULL);
utctime = gmtime(&lasttime);
+ if (!utctime) {
+ DEBUG(1, ("logon_hours_ok: failed to get gmtime. Failing logon for user %s\n",
+ pdb_get_username(sampass) ));
+ return False;
+ }
/* find the corresponding byte and bit */
bitpos = (utctime->tm_wday * 24 + utctime->tm_hour) % 168;
bitmask = 1 << (bitpos % 8);
if (! (hours[bitpos/8] & bitmask)) {
- DEBUG(1,("logon_hours_ok: Account for user %s not allowed to logon at this time (%s).\n",
- pdb_get_username(sampass),
- asctime(localtime(&lasttime)) ));
+ struct tm *t = localtime(&lasttime);
+ if (!t) {
+ asct = "INVALID TIME";
+ } else {
+ asct = asctime(t);
+ if (!asct) {
+ asct = "INVALID TIME";
+ }
+ }
+
+ DEBUG(1, ("logon_hours_ok: Account for user %s not allowed to "
+ "logon at this time (%s).\n",
+ pdb_get_username(sampass), asct ));
return False;
}
+ asct = asctime(utctime);
DEBUG(5,("logon_hours_ok: user %s allowed to logon at this time (%s)\n",
- pdb_get_username(sampass), asctime(utctime) ));
+ pdb_get_username(sampass), asct ? asct : "UNKNOWN TIME" ));
return True;
}
diff --git a/source/auth/auth_util.c b/source/auth/auth_util.c
index 43ae5c1af65..9427c7681ee 100644
--- a/source/auth/auth_util.c
+++ b/source/auth/auth_util.c
@@ -1082,8 +1082,10 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
/* This is a passdb user, so ask passdb */
struct samu *sam_acct = NULL;
+ const DOM_SID *gr_sid = NULL;
if ( !(sam_acct = samu_new( tmp_ctx )) ) {
+ result = NT_STATUS_NO_MEMORY;
goto done;
}
@@ -1094,7 +1096,13 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
goto done;
}
- sid_copy(&primary_group_sid, pdb_get_group_sid(sam_acct));
+ gr_sid = pdb_get_group_sid(sam_acct);
+ if (!gr_sid) {
+ result = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ sid_copy(&primary_group_sid, gr_sid);
if (!sid_to_gid(&primary_group_sid, gid)) {
DEBUG(1, ("sid_to_gid(%s) failed\n",
@@ -1340,25 +1348,44 @@ static auth_serversupplied_info *copy_serverinfo(auth_serversupplied_info *src)
dst->uid = src->uid;
dst->gid = src->gid;
dst->n_groups = src->n_groups;
- if (src->n_groups != 0)
+ if (src->n_groups != 0) {
dst->groups = talloc_memdup(dst, src->groups,
sizeof(gid_t)*dst->n_groups);
- else
+ } else {
dst->groups = NULL;
-
- dst->ptok = dup_nt_token(dst, src->ptok);
+ }
+
+ if (src->ptok) {
+ dst->ptok = dup_nt_token(dst, src->ptok);
+ if (!dst->ptok) {
+ TALLOC_FREE(dst);
+ return NULL;
+ }
+ }
dst->user_session_key = data_blob_talloc( dst, src->user_session_key.data,
- src->user_session_key.length);
-
+ src->user_session_key.length);
+
dst->lm_session_key = data_blob_talloc(dst, src->lm_session_key.data,
- src->lm_session_key.length);
-
- if ( (dst->sam_account = samu_new( NULL )) != NULL )
- pdb_copy_sam_account(dst->sam_account, src->sam_account);
+ src->lm_session_key.length);
+
+ dst->sam_account = samu_new(NULL);
+ if (!dst->sam_account) {
+ TALLOC_FREE(dst);
+ return NULL;
+ }
+
+ if (!pdb_copy_sam_account(dst->sam_account, src->sam_account)) {
+ TALLOC_FREE(dst);
+ return NULL;
+ }
dst->pam_handle = NULL;
dst->unix_name = talloc_strdup(dst, src->unix_name);
+ if (!dst->unix_name) {
+ TALLOC_FREE(dst);
+ return NULL;
+ }
return dst;
}
diff --git a/source/auth/pass_check.c b/source/auth/pass_check.c
index 507e8a3836e..d0a900b80f3 100644
--- a/source/auth/pass_check.c
+++ b/source/auth/pass_check.c
@@ -92,6 +92,7 @@ check on a DCE/DFS authentication
********************************************************************/
static BOOL dfs_auth(char *user, char *password)
{
+ struct tm *t;
error_status_t err;
int err2;
int prterr;
@@ -341,8 +342,13 @@ static BOOL dfs_auth(char *user, char *password)
set_effective_uid(0);
set_effective_gid(0);
- DEBUG(0,
- ("DCE context expires: %s", asctime(localtime(&expire_time))));
+ t = localtime(&expire_time);
+ if (t) {
+ const char *asct = asctime(t);
+ if (asct) {
+ DEBUG(0,("DCE context expires: %s", asct));
+ }
+ }
dcelogin_atmost_once = 1;
return (True);
diff --git a/source/client/client.c b/source/client/client.c
index 1fbee70645c..94fcaaca00d 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -269,7 +269,7 @@ static int do_cd(char *newdir)
else
pstrcat(cur_dir,p);
- if (*(cur_dir+strlen(cur_dir)-1) != '\\') {
+ if ((cur_dir[0] != '\0') && (*(cur_dir+strlen(cur_dir)-1) != '\\')) {
pstrcat(cur_dir, "\\");
}
@@ -379,7 +379,7 @@ static void display_finfo(file_info *finfo)
finfo->name,
attrib_string(finfo->mode),
(double)finfo->size,
- asctime(localtime(&t)));
+ time_to_asc(&t));
dir_total += finfo->size;
}
}
@@ -647,7 +647,7 @@ static int cmd_dir(void)
dir_total = 0;
if (strcmp(cur_dir, "\\") != 0) {
pstrcpy(mask,cur_dir);
- if(mask[strlen(mask)-1]!='\\')
+ if ((mask[0] != '\0') && (mask[strlen(mask)-1]!='\\'))
pstrcat(mask,"\\");
} else {
pstrcpy(mask, "\\");
@@ -686,7 +686,7 @@ static int cmd_du(void)
dir_total = 0;
pstrcpy(mask,cur_dir);
- if(mask[strlen(mask)-1]!='\\')
+ if ((mask[0] != '\0') && (mask[strlen(mask)-1]!='\\'))
pstrcat(mask,"\\");
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
@@ -1008,7 +1008,7 @@ static int cmd_mget(void)
while (next_token_nr(NULL,p,NULL,sizeof(buf))) {
pstrcpy(mget_mask,cur_dir);
- if(mget_mask[strlen(mget_mask)-1]!='\\')
+ if ((mget_mask[0] != '\0') && (mget_mask[strlen(mget_mask)-1]!='\\'))
pstrcat(mget_mask,"\\");
if (*p == '\\')
@@ -2111,6 +2111,7 @@ static int cmd_stat(void)
fstring mode_str;
SMB_STRUCT_STAT sbuf;
struct cli_state *targetcli;
+ struct tm *lt;
pstring targetname;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
@@ -2165,13 +2166,28 @@ static int cmd_stat(void)
(unsigned int)sbuf.st_uid,
(unsigned int)sbuf.st_gid);
- strftime(mode_str, sizeof(mode_str), "%F %T %z", localtime(&sbuf.st_atime));
+ lt = localtime(&sbuf.st_atime);
+ if (lt) {
+ strftime(mode_str, sizeof(mode_str), "%F %T %z", lt);
+ } else {
+ fstrcpy(mode_str, "unknown");
+ }
d_printf("Access: %s\n", mode_str);
- strftime(mode_str, sizeof(mode_str), "%F %T %z", localtime(&sbuf.st_mtime));
+ lt = localtime(&sbuf.st_mtime);
+ if (lt) {
+ strftime(mode_str, sizeof(mode_str), "%F %T %z", lt);
+ } else {
+ fstrcpy(mode_str, "unknown");
+ }
d_printf("Modify: %s\n", mode_str);
- strftime(mode_str, sizeof(mode_str), "%F %T %z", localtime(&sbuf.st_ctime));
+ lt = localtime(&sbuf.st_ctime);
+ if (lt) {
+ strftime(mode_str, sizeof(mode_str), "%F %T %z", lt);
+ } else {
+ fstrcpy(mode_str, "unknown");
+ }
d_printf("Change: %s\n", mode_str);
return 0;
@@ -2339,7 +2355,7 @@ static int cmd_newer(void)
if (ok && (sys_stat(buf,&sbuf) == 0)) {
newer_than = sbuf.st_mtime;
DEBUG(1,("Getting files newer than %s",
- asctime(localtime(&newer_than))));
+ time_to_asc(&newer_than)));
} else {
newer_than = 0;
}
diff --git a/source/client/clitar.c b/source/client/clitar.c
index a7bc4bfde34..14c28acfc5a 100644
--- a/source/client/clitar.c
+++ b/source/client/clitar.c
@@ -1641,7 +1641,7 @@ int tar_parseargs(int argc, char *argv[], const char *Optarg, int Optind)
if (sys_stat(argv[Optind], &stbuf) == 0) {
newer_than = stbuf.st_mtime;
DEBUG(1,("Getting files newer than %s",
- asctime(localtime(&newer_than))));
+ time_to_asc(&newer_than)));
newOptind++;
Optind++;
} else {
diff --git a/source/client/smbctool.c b/source/client/smbctool.c
index ba095aee84e..5b21d195b76 100644
--- a/source/client/smbctool.c
+++ b/source/client/smbctool.c
@@ -445,7 +445,7 @@ static void display_finfo(file_info *finfo)
finfo->name,
attrib_string(finfo->mode),
(double)finfo->size,
- asctime(localtime(&t)));
+ time_to_asc(&t));
dir_total += finfo->size;
}
}
@@ -458,7 +458,7 @@ static void display_stat(char *name, struct stat *st)
{
time_t t = st->st_mtime;
pstring time_str;
- pstrcpy(time_str, asctime(localtime(&t)));
+ pstrcpy(time_str, time_to_asc(&t));
time_str[strlen(time_str)-1] = 0;
d_printf("> %-30s", name);
d_printf("%10.10s %8.0f %s\n", *mode_t_string(st->st_mode), (double)st->st_size, time_str);
@@ -2303,6 +2303,7 @@ static int cmd_stat(void)
fstring mode_str;
SMB_STRUCT_STAT sbuf;
struct cli_state *targetcli;
+ struct tm *lt;
pstring targetname;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
@@ -2357,15 +2358,30 @@ static int cmd_stat(void)
(unsigned int)sbuf.st_uid,
(unsigned int)sbuf.st_gid);
- strftime(mode_str, sizeof(mode_str), "%F %T %z", localtime(&sbuf.st_atime));
+ lt = localtime(&sbuf.st_atime);
+ if (lt) {
+ strftime(mode_str, sizeof(mode_str), "%F %T %z", lt);
+ } else {
+ fstrcpy(mode_str, "unknown");
+ }
d_printf("Access: %s\n", mode_str);
- strftime(mode_str, sizeof(mode_str), "%F %T %z", localtime(&sbuf.st_mtime));
+ lt = localtime(&sbuf.st_mtime);
+ if (lt) {
+ strftime(mode_str, sizeof(mode_str), "%F %T %z", lt);
+ } else {
+ fstrcpy(mode_str, "unknown");
+ }
d_printf("Modify: %s\n", mode_str);
- strftime(mode_str, sizeof(mode_str), "%F %T %z", localtime(&sbuf.st_ctime));
+ lt = localtime(&sbuf.st_ctime);
+ if (lt) {
+ strftime(mode_str, sizeof(mode_str), "%F %T %z", lt);
+ } else {
+ fstrcpy(mode_str, "unknown");
+ }
d_printf("Change: %s\n", mode_str);
-
+
return 0;
}
@@ -2538,7 +2554,7 @@ static int cmd_newer(void)
if (ok && (sys_stat(buf,&sbuf) == 0)) {
newer_than = sbuf.st_mtime;
DEBUG(1,("Getting files newer than %s",
- asctime(localtime(&newer_than))));
+ time_to_asc(&newer_than)));
} else {
newer_than = 0;
}
diff --git a/source/lib/getsmbpass.c b/source/lib/getsmbpass.c
index df5e0359aa2..a7780f7c12b 100644
--- a/source/lib/getsmbpass.c
+++ b/source/lib/getsmbpass.c
@@ -147,8 +147,10 @@ char *getsmbpass(const char *prompt)
fgets(buf, bufsize, in);
}
nread = strlen(buf);
- if (buf[nread - 1] == '\n')
- buf[nread - 1] = '\0';
+ if (nread) {
+ if (buf[nread - 1] == '\n')
+ buf[nread - 1] = '\0';
+ }
/* Restore echoing. */
if (echo_off) {
diff --git a/source/lib/replace.c b/source/lib/replace.c
index 9ef3503d39f..19b37af9386 100644
--- a/source/lib/replace.c
+++ b/source/lib/replace.c
@@ -95,49 +95,50 @@ Corrections by richard.kettlewell@kewill.com
#define YEAR 365*DAY
time_t mktime(struct tm *t)
{
- struct tm *u;
- time_t epoch = 0;
- int n;
- int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
- y, m, i;
-
- if(t->tm_year < 70)
- return((time_t)-1);
-
- n = t->tm_year + 1900 - 1;
- epoch = (t->tm_year - 70) * YEAR +
- ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY;
-
- y = t->tm_year + 1900;
- m = 0;
-
- for(i = 0; i < t->tm_mon; i++) {
- epoch += mon [m] * DAY;
- if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
- epoch += DAY;
+ struct tm *u;
+ time_t epoch = 0;
+ int n;
+ int mon [] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+ y, m, i;
+
+ if(t->tm_year < 70) {
+ return((time_t)-1);
+ }
+
+ n = t->tm_year + 1900 - 1;
+ epoch = (t->tm_year - 70) * YEAR + ((n / 4 - n / 100 + n / 400) - (1969 / 4 - 1969 / 100 + 1969 / 400)) * DAY;
+
+ y = t->tm_year + 1900;
+ m = 0;
+
+ for(i = 0; i < t->tm_mon; i++) {
+ epoch += mon [m] * DAY;
+ if(m == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
+ epoch += DAY;
+ }
- if(++m > 11) {
- m = 0;
- y++;
- }
- }
-
- epoch += (t->tm_mday - 1) * DAY;
- epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec;
+ if(++m > 11) {
+ m = 0;
+ y++;
+ }
+ }
+
+ epoch += (t->tm_mday - 1) * DAY;
+ epoch += t->tm_hour * HOUR + t->tm_min * MINUTE + t->tm_sec;
- if((u = localtime(&epoch)) != NULL) {
- t->tm_sec = u->tm_sec;
- t->tm_min = u->tm_min;
- t->tm_hour = u->tm_hour;
- t->tm_mday = u->tm_mday;
- t->tm_mon = u->tm_mon;
- t->tm_year = u->tm_year;
- t->tm_wday = u->tm_wday;
- t->tm_yday = u->tm_yday;
- t->tm_isdst = u->tm_isdst;
- }
-
- return(epoch);
+ if((u = localtime(&epoch)) != NULL) {
+ t->tm_sec = u->tm_sec;
+ t->tm_min = u->tm_min;
+ t->tm_hour = u->tm_hour;
+ t->tm_mday = u->tm_mday;
+ t->tm_mon = u->tm_mon;
+ t->tm_year = u->tm_year;
+ t->tm_wday = u->tm_wday;
+ t->tm_yday = u->tm_yday;
+ t->tm_isdst = u->tm_isdst;
+ }
+
+ return(epoch);
}
#endif /* !HAVE_MKTIME */
@@ -147,15 +148,15 @@ Corrections by richard.kettlewell@kewill.com
/* Rename a file. (from libiberty in GNU binutils) */
int rename(const char *zfrom, const char *zto)
{
- if (link (zfrom, zto) < 0)
- {
- if (errno != EEXIST)
- return -1;
- if (unlink (zto) < 0
- || link (zfrom, zto) < 0)
- return -1;
- }
- return unlink (zfrom);
+ if (link (zfrom, zto) < 0) {
+ if (errno != EEXIST) {
+ return -1;
+ }
+ if (unlink (zto) < 0 || link (zfrom, zto) < 0) {
+ return -1;
+ }
+ }
+ return unlink (zfrom);
}
#endif /* HAVE_RENAME */
diff --git a/source/lib/time.c b/source/lib/time.c
index f8a1538910c..9a539d415e8 100644
--- a/source/lib/time.c
+++ b/source/lib/time.c
@@ -615,16 +615,19 @@ char *http_timestring(time_t t)
static fstring buf;
struct tm *tm = localtime(&t);
- if (!tm)
+ if (!tm) {
slprintf(buf,sizeof(buf)-1,"%ld seconds since the Epoch",(long)t);
- else
+ } else {
#ifndef HAVE_STRFTIME
- fstrcpy(buf, asctime(tm));
- if(buf[strlen(buf)-1] == '\n')
+ const char *asct = asctime(tm);
+ fstrcpy(buf, asct ? asct : "unknown");
+ }
+ if(buf[strlen(buf)-1] == '\n') {
buf[strlen(buf)-1] = 0;
#else /* !HAVE_STRFTIME */
strftime(buf, sizeof(buf)-1, "%a, %d %b %Y %H:%M:%S %Z", tm);
#endif /* !HAVE_STRFTIME */
+ }
return buf;
}
@@ -672,13 +675,15 @@ char *timestring(BOOL hires)
}
#else
if (hires) {
+ const char *asct = asctime(tm);
slprintf(TimeBuf,
sizeof(TimeBuf)-1,
"%s.%06ld",
- asctime(tm),
+ asct ? asct : "unknown",
(long)tp.tv_usec);
} else {
- fstrcpy(TimeBuf, asctime(tm));
+ const char *asct = asctime(tm);
+ fstrcpy(TimeBuf, asct ? asct : "unknown");
}
#endif
}
@@ -1050,3 +1055,24 @@ struct timespec get_create_timespec(SMB_STRUCT_STAT *st,BOOL fake_dirs)
return ret;
}
#endif
+
+/****************************************************************************
+ Utility function that always returns a const string even if localtime
+ and asctime fail.
+****************************************************************************/
+
+const char *time_to_asc(const time_t *t)
+{
+ const char *asct;
+ struct tm *lt = localtime(t);
+
+ if (!lt) {
+ return "unknown time";
+ }
+
+ asct = asctime(lt);
+ if (!asct) {
+ return "unknown time";
+ }
+ return asct;
+}
diff --git a/source/libads/ads_struct.c b/source/libads/ads_struct.c
index e546f2ae8ab..7a03a2a80f6 100644
--- a/source/libads/ads_struct.c
+++ b/source/libads/ads_struct.c
@@ -48,16 +48,18 @@ char *ads_build_path(const char *realm, const char *sep, const char *field, int
strlcpy(ret,field, len);
p=strtok(r,sep);
- strlcat(ret, p, len);
-
- while ((p=strtok(NULL,sep))) {
- char *s;
- if (reverse)
- asprintf(&s, "%s%s,%s", field, p, ret);
- else
- asprintf(&s, "%s,%s%s", ret, field, p);
- free(ret);
- ret = s;
+ if (p) {
+ strlcat(ret, p, len);
+
+ while ((p=strtok(NULL,sep))) {
+ char *s;
+ if (reverse)
+ asprintf(&s, "%s%s,%s", field, p, ret);
+ else
+ asprintf(&s, "%s,%s%s", ret, field, p);
+ free(ret);
+ ret = s;
+ }
}
free(r);
diff --git a/source/libads/krb5_setpw.c b/source/libads/krb5_setpw.c
index 254ca7b2a3a..ec2ff5afb1a 100644
--- a/source/libads/krb5_setpw.c
+++ b/source/libads/krb5_setpw.c
@@ -528,7 +528,6 @@ ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ,
DEBUG(1,("Failed to parse kadmin/changepw (%s)\n", error_message(ret)));
return ADS_ERROR_KRB5(ret);
}
- free(princ_name);
/* parse the principal we got as a function argument */
ret = smb_krb5_parse_name(context, princ, &principal);
@@ -537,9 +536,12 @@ ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ,
krb5_free_principal(context, creds.server);
krb5_free_context(context);
DEBUG(1,("Failed to parse %s (%s)\n", princ_name, error_message(ret)));
+ free(princ_name);
return ADS_ERROR_KRB5(ret);
}
+ free(princ_name);
+
/* The creds.server principal takes ownership of this memory.
Remember to set back to original value before freeing. */
orig_realm = *krb5_princ_realm(context, creds.server);
diff --git a/source/libsmb/asn1.c b/source/libsmb/asn1.c
index 072fd302830..8c986c9588f 100644
--- a/source/libsmb/asn1.c
+++ b/source/libsmb/asn1.c
@@ -268,17 +268,22 @@ BOOL asn1_start_tag(ASN1_DATA *data, uint8 tag)
}
if (!asn1_read_uint8(data, &b)) {
+ SAFE_FREE(nesting);
return False;
}
if (b & 0x80) {
int n = b & 0x7f;
- if (!asn1_read_uint8(data, &b))
+ if (!asn1_read_uint8(data, &b)) {
+ SAFE_FREE(nesting);
return False;
+ }
nesting->taglen = b;
while (n > 1) {
- if (!asn1_read_uint8(data, &b))
+ if (!asn1_read_uint8(data, &b)) {
+ SAFE_FREE(nesting);
return False;
+ }
nesting->taglen = (nesting->taglen << 8) | b;
n--;
}
@@ -335,7 +340,11 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID)
pstring oid_str;
fstring el;
- if (!asn1_start_tag(data, ASN1_OID)) return False;
+ *OID = NULL;
+
+ if (!asn1_start_tag(data, ASN1_OID)) {
+ return False;
+ }
asn1_read_uint8(data, &b);
oid_str[0] = 0;
@@ -356,7 +365,9 @@ BOOL asn1_read_OID(ASN1_DATA *data, char **OID)
asn1_end_tag(data);
- *OID = SMB_STRDUP(oid_str);
+ if (!data->has_error) {
+ *OID = SMB_STRDUP(oid_str);
+ }
return !data->has_error;
}
@@ -366,7 +377,9 @@ BOOL asn1_check_OID(ASN1_DATA *data, const char *OID)
{
char *id;
- if (!asn1_read_OID(data, &id)) return False;
+ if (!asn1_read_OID(data, &id)) {
+ return False;
+ }
if (strcmp(id, OID) != 0) {
data->has_error = True;
diff --git a/source/libsmb/clidfs.c b/source/libsmb/clidfs.c
index 03cfd4dd400..298f4d1b548 100644
--- a/source/libsmb/clidfs.c
+++ b/source/libsmb/clidfs.c
@@ -415,7 +415,7 @@ static void clean_path( pstring clean, const char *path )
/* strip a trailing backslash */
len = strlen( newpath );
- if ( newpath[len-1] == '\\' )
+ if ( (len > 0) && (newpath[len-1] == '\\') )
newpath[len-1] = '\0';
pstrcpy( clean, newpath );
diff --git a/source/nmbd/nmbd_become_dmb.c b/source/nmbd/nmbd_become_dmb.c
index fb1fb33a818..523ec6cabf1 100644
--- a/source/nmbd/nmbd_become_dmb.c
+++ b/source/nmbd/nmbd_become_dmb.c
@@ -120,6 +120,7 @@ in workgroup %s on subnet %s\n",
if( subrec == unicast_subnet ) {
struct nmb_name nmbname;
struct in_addr my_first_ip;
+ struct in_addr *nip;
/* Put our name and first IP address into the
workgroup struct as domain master browser. This
@@ -130,7 +131,14 @@ in workgroup %s on subnet %s\n",
work->dmb_name = nmbname;
/* Pick the first interface ip address as the domain master browser ip. */
- my_first_ip = *iface_n_ip(0);
+ nip = iface_n_ip(0);
+
+ if (!nip) {
+ DEBUG(0,("become_domain_master_stage2: Error. iface_n_ip returned NULL\n"));
+ return;
+ }
+
+ my_first_ip = *nip;
putip((char *)&work->dmb_addr, &my_first_ip);
diff --git a/source/nmbd/nmbd_namelistdb.c b/source/nmbd/nmbd_namelistdb.c
index 60023a7ed5e..fb32ce1aad1 100644
--- a/source/nmbd/nmbd_namelistdb.c
+++ b/source/nmbd/nmbd_namelistdb.c
@@ -564,15 +564,31 @@ void dump_name_record( struct name_record *namerec, XFILE *fp)
x_fprintf(fp,"Source = %s\nb_flags = %x\t", src_type, namerec->data.nb_flags);
if(namerec->data.death_time != PERMANENT_TTL) {
+ const char *asct;
tm = localtime(&namerec->data.death_time);
- x_fprintf(fp, "death_time = %s\t", asctime(tm));
+ if (!tm) {
+ return;
+ }
+ asct = asctime(tm);
+ if (!asct) {
+ return;
+ }
+ x_fprintf(fp, "death_time = %s\t", asct);
} else {
x_fprintf(fp, "death_time = PERMANENT\t");
}
if(namerec->data.refresh_time != PERMANENT_TTL) {
+ const char *asct;
tm = localtime(&namerec->data.refresh_time);
- x_fprintf(fp, "refresh_time = %s\n", asctime(tm));
+ if (!tm) {
+ return;
+ }
+ asct = asctime(tm);
+ if (!asct) {
+ return;
+ }
+ x_fprintf(fp, "refresh_time = %s\n", asct);
} else {
x_fprintf(fp, "refresh_time = PERMANENT\n");
}
diff --git a/source/nmbd/nmbd_subnetdb.c b/source/nmbd/nmbd_subnetdb.c
index c3640028d27..5a93d8bec03 100644
--- a/source/nmbd/nmbd_subnetdb.c
+++ b/source/nmbd/nmbd_subnetdb.c
@@ -220,7 +220,13 @@ BOOL create_subnets(void)
if (lp_we_are_a_wins_server()) {
/* Pick the first interface ip address as the WINS server ip. */
- unicast_ip = *iface_n_ip(0);
+ struct in_addr *nip = iface_n_ip(0);
+
+ if (!nip) {
+ return False;
+ }
+
+ unicast_ip = *nip;
} else {
/* note that we do not set the wins server IP here. We just
set it at zero and let the wins registration code cope
diff --git a/source/nmbd/nmbd_winsserver.c b/source/nmbd/nmbd_winsserver.c
index 198d90f35a1..29d5c41de82 100644
--- a/source/nmbd/nmbd_winsserver.c
+++ b/source/nmbd/nmbd_winsserver.c
@@ -2222,7 +2222,13 @@ void wins_write_name_record(struct name_record *namerec, XFILE *fp)
char *ts, *nl;
tm = localtime(&namerec->data.death_time);
+ if (!tm) {
+ return;
+ }
ts = asctime(tm);
+ if (!ts) {
+ return;
+ }
nl = strrchr( ts, '\n' );
if( NULL != nl ) {
*nl = '\0';
diff --git a/source/nsswitch/winbindd_cache.c b/source/nsswitch/winbindd_cache.c
index 0c096352d39..86846f7835c 100644
--- a/source/nsswitch/winbindd_cache.c
+++ b/source/nsswitch/winbindd_cache.c
@@ -717,7 +717,7 @@ static void wcache_save_name_to_sid(struct winbindd_domain *domain,
fstrcpy(uname, name);
strupper_m(uname);
centry_end(centry, "NS/%s/%s", domain_name, uname);
- DEBUG(10,("wcache_save_name_to_sid: %s -> %s\n", uname,
+ DEBUG(10,("wcache_save_name_to_sid: %s\\%s -> %s\n", domain_name, uname,
sid_string_static(sid)));
centry_free(centry);
}
@@ -870,8 +870,8 @@ NTSTATUS wcache_get_creds(struct winbindd_domain *domain,
#endif
status = centry->status;
- DEBUG(10,("wcache_get_creds: [Cached] - cached creds for user %s status %s\n",
- sid_string_static(sid), get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("wcache_get_creds: [Cached] - cached creds for user %s status: %s\n",
+ sid_string_static(sid), nt_errstr(status) ));
centry_free(centry);
return status;
@@ -953,8 +953,8 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
do_cached:
status = centry->status;
- DEBUG(10,("query_user_list: [Cached] - cached list for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("query_user_list: [Cached] - cached list for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1065,8 +1065,8 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
do_cached:
status = centry->status;
- DEBUG(10,("enum_dom_groups: [Cached] - cached list for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("enum_dom_groups: [Cached] - cached list for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1148,8 +1148,8 @@ do_cached:
} else
status = centry->status;
- DEBUG(10,("enum_local_groups: [Cached] - cached list for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("enum_local_groups: [Cached] - cached list for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1213,8 +1213,8 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
centry_sid(centry, mem_ctx, sid);
}
- DEBUG(10,("name_to_sid: [Cached] - cached name for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("name_to_sid: [Cached] - cached name for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1279,8 +1279,8 @@ static NTSTATUS sid_to_name(struct winbindd_domain *domain,
}
status = centry->status;
- DEBUG(10,("sid_to_name: [Cached] - cached name for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("sid_to_name: [Cached] - cached name for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1353,8 +1353,8 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
centry_sid(centry, mem_ctx, &info->group_sid);
status = centry->status;
- DEBUG(10,("query_user: [Cached] - cached info for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("query_user: [Cached] - cached info for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1427,8 +1427,8 @@ static NTSTATUS lookup_usergroups(struct winbindd_domain *domain,
do_cached:
status = centry->status;
- DEBUG(10,("lookup_usergroups: [Cached] - cached info for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("lookup_usergroups: [Cached] - cached info for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1513,9 +1513,8 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain,
status = centry->status;
- DEBUG(10,("lookup_useraliases: [Cached] - cached info for domain %s "
- "status %s\n", domain->name,
- get_friendly_nt_error_msg(status)));
+ DEBUG(10,("lookup_useraliases: [Cached] - cached info for domain: %s "
+ "status %s\n", domain->name, nt_errstr(status)));
centry_free(centry);
return status;
@@ -1591,8 +1590,8 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
do_cached:
status = centry->status;
- DEBUG(10,("lookup_groupmem: [Cached] - cached info for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("lookup_groupmem: [Cached] - cached info for domain %s status: %s\n",
+ domain->name, nt_errstr(status)));
centry_free(centry);
return status;
@@ -1684,8 +1683,8 @@ static NTSTATUS trusted_domains(struct winbindd_domain *domain,
status = centry->status;
- DEBUG(10,("trusted_domains: [Cached] - cached info for domain %s (%d trusts) status %s\n",
- domain->name, *num_domains, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("trusted_domains: [Cached] - cached info for domain %s (%d trusts) status: %s\n",
+ domain->name, *num_domains, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1760,8 +1759,8 @@ static NTSTATUS lockout_policy(struct winbindd_domain *domain,
status = centry->status;
- DEBUG(10,("lockout_policy: [Cached] - cached info for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("lockout_policy: [Cached] - cached info for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -1811,8 +1810,8 @@ static NTSTATUS password_policy(struct winbindd_domain *domain,
status = centry->status;
- DEBUG(10,("lockout_policy: [Cached] - cached info for domain %s status %s\n",
- domain->name, get_friendly_nt_error_msg(status) ));
+ DEBUG(10,("lockout_policy: [Cached] - cached info for domain %s status: %s\n",
+ domain->name, nt_errstr(status) ));
centry_free(centry);
return status;
@@ -2232,7 +2231,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
ret = tdb_traverse(cache->tdb, traverse_fn_get_credlist, NULL);
if (ret == 0) {
return NT_STATUS_OK;
- } else if (ret == -1) {
+ } else if ((ret == -1) || (wcache_cred_list == NULL)) {
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
diff --git a/source/nsswitch/winbindd_rpc.c b/source/nsswitch/winbindd_rpc.c
index 22df8d4db96..de4dbc9a79b 100644
--- a/source/nsswitch/winbindd_rpc.c
+++ b/source/nsswitch/winbindd_rpc.c
@@ -262,7 +262,7 @@ NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
return NT_STATUS_NO_MEMORY;
}
- DEBUG(3,("name_to_sid [rpc] %s for domain %s\n", name?name:"", domain_name ));
+ DEBUG(3,("name_to_sid [rpc] %s for domain %s\n", full_name?full_name:"", domain_name ));
result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
if (!NT_STATUS_IS_OK(result))
diff --git a/source/pam_smbpass/pam_smb_acct.c b/source/pam_smbpass/pam_smb_acct.c
index 8970ffa8edf..47bf0594798 100644
--- a/source/pam_smbpass/pam_smb_acct.c
+++ b/source/pam_smbpass/pam_smb_acct.c
@@ -42,72 +42,80 @@
int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
int argc, const char **argv )
{
- unsigned int ctrl;
- int retval;
-
- const char *name;
- struct samu *sampass = NULL;
- void (*oldsig_handler)(int);
- extern BOOL in_client;
-
- /* Samba initialization. */
- load_case_tables();
- setup_logging( "pam_smbpass", False );
- in_client = True;
-
- ctrl = set_ctrl( flags, argc, argv );
-
- /* get the username */
-
- retval = pam_get_user( pamh, &name, "Username: " );
- if (retval != PAM_SUCCESS) {
- if (on( SMB_DEBUG, ctrl )) {
- _log_err( LOG_DEBUG, "acct: could not identify user" );
- }
- return retval;
- }
- if (on( SMB_DEBUG, ctrl )) {
- _log_err( LOG_DEBUG, "acct: username [%s] obtained", name );
- }
-
- /* Getting into places that might use LDAP -- protect the app
- from a SIGPIPE it's not expecting */
- oldsig_handler = CatchSignal(SIGPIPE, SIGNAL_CAST SIG_IGN);
- if (!initialize_password_db(True)) {
- _log_err( LOG_ALERT, "Cannot access samba password database" );
- CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
- return PAM_AUTHINFO_UNAVAIL;
- }
-
- /* Get the user's record. */
-
- if ( (sampass = samu_new( NULL )) != NULL ) {
- pdb_getsampwnam(sampass, name );
- }
-
- /* check for lookup failure */
- if ( !sampass || !strlen(pdb_get_username(sampass)) ) {
- CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
- return PAM_USER_UNKNOWN;
- }
-
- if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) {
- if (on( SMB_DEBUG, ctrl )) {
- _log_err( LOG_DEBUG
- , "acct: account %s is administratively disabled", name );
- }
- make_remark( pamh, ctrl, PAM_ERROR_MSG
- , "Your account has been disabled; "
- "please see your system administrator." );
-
- CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
- return PAM_ACCT_EXPIRED;
- }
-
- /* TODO: support for expired passwords. */
-
- CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
- return PAM_SUCCESS;
+ unsigned int ctrl;
+ int retval;
+
+ const char *name;
+ struct samu *sampass = NULL;
+ void (*oldsig_handler)(int);
+ extern BOOL in_client;
+
+ /* Samba initialization. */
+ load_case_tables();
+ setup_logging( "pam_smbpass", False );
+ in_client = True;
+
+ ctrl = set_ctrl( flags, argc, argv );
+
+ /* get the username */
+
+ retval = pam_get_user( pamh, &name, "Username: " );
+ if (retval != PAM_SUCCESS) {
+ if (on( SMB_DEBUG, ctrl )) {
+ _log_err( LOG_DEBUG, "acct: could not identify user" );
+ }
+ return retval;
+ }
+ if (on( SMB_DEBUG, ctrl )) {
+ _log_err( LOG_DEBUG, "acct: username [%s] obtained", name );
+ }
+
+ /* Getting into places that might use LDAP -- protect the app
+ from a SIGPIPE it's not expecting */
+ oldsig_handler = CatchSignal(SIGPIPE, SIGNAL_CAST SIG_IGN);
+ if (!initialize_password_db(True)) {
+ _log_err( LOG_ALERT, "Cannot access samba password database" );
+ CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
+ return PAM_AUTHINFO_UNAVAIL;
+ }
+
+ /* Get the user's record. */
+
+ if (!(sampass = samu_new( NULL ))) {
+ CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
+ /* malloc fail. */
+ return nt_status_to_pam(NT_STATUS_NO_MEMORY);
+ }
+
+ if (!pdb_getsampwnam(sampass, name )) {
+ _log_err( LOG_DEBUG, "acct: could not identify user" );
+ CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
+ return PAM_USER_UNKNOWN;
+ }
+
+ /* check for lookup failure */
+ if (!strlen(pdb_get_username(sampass)) ) {
+ CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
+ return PAM_USER_UNKNOWN;
+ }
+
+ if (pdb_get_acct_ctrl(sampass) & ACB_DISABLED) {
+ if (on( SMB_DEBUG, ctrl )) {
+ _log_err( LOG_DEBUG
+ , "acct: account %s is administratively disabled", name );
+ }
+ make_remark( pamh, ctrl, PAM_ERROR_MSG
+ , "Your account has been disabled; "
+ "please see your system administrator." );
+
+ CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
+ return PAM_ACCT_EXPIRED;
+ }
+
+ /* TODO: support for expired passwords. */
+
+ CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
+ return PAM_SUCCESS;
}
/* static module data */
diff --git a/source/pam_smbpass/pam_smb_auth.c b/source/pam_smbpass/pam_smb_auth.c
index 15726aa8552..df6d20e01ab 100644
--- a/source/pam_smbpass/pam_smb_auth.c
+++ b/source/pam_smbpass/pam_smb_auth.c
@@ -62,94 +62,97 @@ static int _smb_add_user(pam_handle_t *pamh, unsigned int ctrl,
int pam_sm_authenticate(pam_handle_t *pamh, int flags,
int argc, const char **argv)
{
- unsigned int ctrl;
- int retval, *ret_data = NULL;
- struct samu *sampass = NULL;
- extern BOOL in_client;
- const char *name;
- void (*oldsig_handler)(int) = NULL;
- BOOL found;
-
- /* Points to memory managed by the PAM library. Do not free. */
- char *p = NULL;
-
-
- /* Samba initialization. */
- load_case_tables();
- setup_logging("pam_smbpass",False);
- in_client = True;
-
- ctrl = set_ctrl(flags, argc, argv);
-
- /* Get a few bytes so we can pass our return value to
- pam_sm_setcred(). */
- ret_data = SMB_MALLOC_P(int);
-
- /* we need to do this before we call AUTH_RETURN */
- /* Getting into places that might use LDAP -- protect the app
- from a SIGPIPE it's not expecting */
- oldsig_handler = CatchSignal(SIGPIPE, SIGNAL_CAST SIG_IGN);
-
- /* get the username */
- retval = pam_get_user( pamh, &name, "Username: " );
- if ( retval != PAM_SUCCESS ) {
- if (on( SMB_DEBUG, ctrl )) {
- _log_err(LOG_DEBUG, "auth: could not identify user");
- }
- AUTH_RETURN;
- }
- if (on( SMB_DEBUG, ctrl )) {
- _log_err( LOG_DEBUG, "username [%s] obtained", name );
- }
+ unsigned int ctrl;
+ int retval, *ret_data = NULL;
+ struct samu *sampass = NULL;
+ extern BOOL in_client;
+ const char *name;
+ void (*oldsig_handler)(int) = NULL;
+ BOOL found;
+
+ /* Points to memory managed by the PAM library. Do not free. */
+ char *p = NULL;
+
+ /* Samba initialization. */
+ load_case_tables();
+ setup_logging("pam_smbpass",False);
+ in_client = True;
+
+ ctrl = set_ctrl(flags, argc, argv);
+
+ /* Get a few bytes so we can pass our return value to
+ pam_sm_setcred(). */
+ ret_data = SMB_MALLOC_P(int);
+
+ /* we need to do this before we call AUTH_RETURN */
+ /* Getting into places that might use LDAP -- protect the app
+ from a SIGPIPE it's not expecting */
+ oldsig_handler = CatchSignal(SIGPIPE, SIGNAL_CAST SIG_IGN);
+
+ /* get the username */
+ retval = pam_get_user( pamh, &name, "Username: " );
+ if ( retval != PAM_SUCCESS ) {
+ if (on( SMB_DEBUG, ctrl )) {
+ _log_err(LOG_DEBUG, "auth: could not identify user");
+ }
+ AUTH_RETURN;
+ }
+ if (on( SMB_DEBUG, ctrl )) {
+ _log_err( LOG_DEBUG, "username [%s] obtained", name );
+ }
- if (!initialize_password_db(True)) {
- _log_err( LOG_ALERT, "Cannot access samba password database" );
- retval = PAM_AUTHINFO_UNAVAIL;
- AUTH_RETURN;
- }
+ if (!initialize_password_db(True)) {
+ _log_err( LOG_ALERT, "Cannot access samba password database" );
+ retval = PAM_AUTHINFO_UNAVAIL;
+ AUTH_RETURN;
+ }
- sampass = samu_new( NULL );
-
- found = pdb_getsampwnam( sampass, name );
+ sampass = samu_new( NULL );
+ if (!sampass) {
+ _log_err( LOG_ALERT, "Cannot talloc a samu struct" );
+ retval = nt_status_to_pam(NT_STATUS_NO_MEMORY);
+ AUTH_RETURN;
+ }
- if (on( SMB_MIGRATE, ctrl )) {
- retval = _smb_add_user(pamh, ctrl, name, sampass, found);
- TALLOC_FREE(sampass);
- AUTH_RETURN;
- }
+ found = pdb_getsampwnam( sampass, name );
- if (!found) {
- _log_err(LOG_ALERT, "Failed to find entry for user %s.", name);
- retval = PAM_USER_UNKNOWN;
- TALLOC_FREE(sampass);
- sampass = NULL;
- AUTH_RETURN;
- }
+ if (on( SMB_MIGRATE, ctrl )) {
+ retval = _smb_add_user(pamh, ctrl, name, sampass, found);
+ TALLOC_FREE(sampass);
+ AUTH_RETURN;
+ }
+
+ if (!found) {
+ _log_err(LOG_ALERT, "Failed to find entry for user %s.", name);
+ retval = PAM_USER_UNKNOWN;
+ TALLOC_FREE(sampass);
+ sampass = NULL;
+ AUTH_RETURN;
+ }
- /* if this user does not have a password... */
+ /* if this user does not have a password... */
- if (_smb_blankpasswd( ctrl, sampass )) {
- TALLOC_FREE(sampass);
- retval = PAM_SUCCESS;
- AUTH_RETURN;
- }
+ if (_smb_blankpasswd( ctrl, sampass )) {
+ TALLOC_FREE(sampass);
+ retval = PAM_SUCCESS;
+ AUTH_RETURN;
+ }
- /* get this user's authentication token */
+ /* get this user's authentication token */
- retval = _smb_read_password(pamh, ctrl, NULL, "Password: ", NULL, _SMB_AUTHTOK, &p);
- if (retval != PAM_SUCCESS ) {
- _log_err(LOG_CRIT, "auth: no password provided for [%s]"
- , name);
- TALLOC_FREE(sampass);
- AUTH_RETURN;
- }
+ retval = _smb_read_password(pamh, ctrl, NULL, "Password: ", NULL, _SMB_AUTHTOK, &p);
+ if (retval != PAM_SUCCESS ) {
+ _log_err(LOG_CRIT, "auth: no password provided for [%s]", name);
+ TALLOC_FREE(sampass);
+ AUTH_RETURN;
+ }
- /* verify the password of this user */
+ /* verify the password of this user */
- retval = _smb_verify_password( pamh, sampass, p, ctrl );
- TALLOC_FREE(sampass);
- p = NULL;
- AUTH_RETURN;
+ retval = _smb_verify_password( pamh, sampass, p, ctrl );
+ TALLOC_FREE(sampass);
+ p = NULL;
+ AUTH_RETURN;
}
/*
@@ -255,4 +258,3 @@ struct pam_module _pam_smbpass_auth_modstruct = {
NULL
};
#endif
-
diff --git a/source/passdb/passdb.c b/source/passdb/passdb.c
index 43171df8b07..d4e788ff680 100644
--- a/source/passdb/passdb.c
+++ b/source/passdb/passdb.c
@@ -67,7 +67,7 @@ static int samu_destroy(void *p)
generate a new struct samuser
***********************************************************************/
-struct samu* samu_new( TALLOC_CTX *ctx )
+struct samu *samu_new( TALLOC_CTX *ctx )
{
struct samu *user;
@@ -634,7 +634,7 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
char *err_str, size_t err_str_len,
char *msg_str, size_t msg_str_len)
{
- struct samu *sam_pass=NULL;
+ struct samu *sam_pass=NULL;
uint32 other_acb;
NTSTATUS result;
@@ -1094,12 +1094,6 @@ uint32 init_buffer_from_sam_v3 (uint8 **buf, struct samu *sampass, BOOL size_onl
uint32 nt_pw_hist_len;
uint32 pwHistLen = 0;
- /* do we have a valid struct samu pointer? */
- if (sampass == NULL) {
- DEBUG(0, ("init_buffer_from_sam: struct samu is NULL!\n"));
- return -1;
- }
-
*buf = NULL;
buflen = 0;
@@ -1330,27 +1324,31 @@ uint32 init_buffer_from_sam_v3 (uint8 **buf, struct samu *sampass, BOOL size_onl
BOOL pdb_copy_sam_account(struct samu *dst, struct samu *src )
{
- BOOL result;
- uint8 *buf;
+ uint8 *buf = NULL;
int len;
- if ( !dst )
- return False;
-
len = init_buffer_from_sam_v3(&buf, src, False);
+ if (len == -1 || !buf) {
+ return False;
+ }
- if (len == -1)
+ if (!init_sam_from_buffer_v3( dst, buf, len )) {
+ free(buf);
return False;
+ }
- result = init_sam_from_buffer_v3( dst, buf, len );
dst->methods = src->methods;
- if ( src->unix_pw )
+ if ( src->unix_pw ) {
dst->unix_pw = tcopy_passwd( dst, src->unix_pw );
+ if (!dst->unix_pw) {
+ free(buf);
+ return False;
+ }
+ }
free(buf);
-
- return result;
+ return True;
}
/*********************************************************************
@@ -1363,8 +1361,6 @@ BOOL pdb_update_bad_password_count(struct samu *sampass, BOOL *updated)
uint16 BadPasswordCount;
uint32 resettime;
- if (!sampass) return False;
-
BadPasswordCount = pdb_get_bad_password_count(sampass);
if (!BadPasswordCount) {
DEBUG(9, ("No bad password attempts.\n"));
@@ -1405,8 +1401,6 @@ BOOL pdb_update_autolock_flag(struct samu *sampass, BOOL *updated)
uint32 duration;
time_t LastBadPassword;
- if (!sampass) return False;
-
if (!(pdb_get_acct_ctrl(sampass) & ACB_AUTOLOCK)) {
DEBUG(9, ("pdb_update_autolock_flag: Account %s not autolocked, no check needed\n",
pdb_get_username(sampass)));
@@ -1459,9 +1453,6 @@ BOOL pdb_increment_bad_password_count(struct samu *sampass)
BOOL autolock_updated = False, badpw_updated = False;
BOOL ret;
- if (!sampass)
- return False;
-
/* Retrieve the account lockout policy */
become_root();
ret = pdb_get_account_policy(AP_BAD_ATTEMPT_LOCKOUT, &account_policy_lockout);
diff --git a/source/passdb/pdb_get_set.c b/source/passdb/pdb_get_set.c
index 0b93c42a416..831ddefa13c 100644
--- a/source/passdb/pdb_get_set.c
+++ b/source/passdb/pdb_get_set.c
@@ -40,127 +40,81 @@
Collection of get...() functions for struct samu.
********************************************************************/
-uint32 pdb_get_acct_ctrl (const struct samu *sampass)
+uint32 pdb_get_acct_ctrl(const struct samu *sampass)
{
- if (sampass)
- return (sampass->acct_ctrl);
- else
- return (ACB_DISABLED);
+ return sampass->acct_ctrl;
}
-time_t pdb_get_logon_time (const struct samu *sampass)
+time_t pdb_get_logon_time(const struct samu *sampass)
{
- if (sampass)
- return (sampass->logon_time);
- else
- return (0);
+ return sampass->logon_time;
}
-time_t pdb_get_logoff_time (const struct samu *sampass)
+time_t pdb_get_logoff_time(const struct samu *sampass)
{
- if (sampass)
- return (sampass->logoff_time);
- else
- return (-1);
+ return sampass->logoff_time;
}
-time_t pdb_get_kickoff_time (const struct samu *sampass)
+time_t pdb_get_kickoff_time(const struct samu *sampass)
{
- if (sampass)
- return (sampass->kickoff_time);
- else
- return (-1);
+ return sampass->kickoff_time;
}
-time_t pdb_get_bad_password_time (const struct samu *sampass)
+time_t pdb_get_bad_password_time(const struct samu *sampass)
{
- if (sampass)
- return (sampass->bad_password_time);
- else
- return (-1);
+ return sampass->bad_password_time;
}
-time_t pdb_get_pass_last_set_time (const struct samu *sampass)
+time_t pdb_get_pass_last_set_time(const struct samu *sampass)
{
- if (sampass)
- return (sampass->pass_last_set_time);
- else
- return (-1);
+ return sampass->pass_last_set_time;
}
-time_t pdb_get_pass_can_change_time (const struct samu *sampass)
+time_t pdb_get_pass_can_change_time(const struct samu *sampass)
{
- if (sampass)
- return (sampass->pass_can_change_time);
- else
- return (-1);
+ return sampass->pass_can_change_time;
}
-time_t pdb_get_pass_must_change_time (const struct samu *sampass)
+time_t pdb_get_pass_must_change_time(const struct samu *sampass)
{
- if (sampass)
- return (sampass->pass_must_change_time);
- else
- return (-1);
+ return sampass->pass_must_change_time;
}
-uint16 pdb_get_logon_divs (const struct samu *sampass)
+uint16 pdb_get_logon_divs(const struct samu *sampass)
{
- if (sampass)
- return (sampass->logon_divs);
- else
- return (-1);
+ return sampass->logon_divs;
}
-uint32 pdb_get_hours_len (const struct samu *sampass)
+uint32 pdb_get_hours_len(const struct samu *sampass)
{
- if (sampass)
- return (sampass->hours_len);
- else
- return (-1);
+ return sampass->hours_len;
}
-const uint8* pdb_get_hours (const struct samu *sampass)
+const uint8 *pdb_get_hours(const struct samu *sampass)
{
- if (sampass)
- return (sampass->hours);
- else
- return (NULL);
+ return (sampass->hours);
}
-const uint8* pdb_get_nt_passwd (const struct samu *sampass)
+const uint8 *pdb_get_nt_passwd(const struct samu *sampass)
{
- if (sampass) {
- SMB_ASSERT((!sampass->nt_pw.data)
- || sampass->nt_pw.length == NT_HASH_LEN);
- return ((uint8*)sampass->nt_pw.data);
- }
- else
- return (NULL);
+ SMB_ASSERT((!sampass->nt_pw.data)
+ || sampass->nt_pw.length == NT_HASH_LEN);
+ return (uint8 *)sampass->nt_pw.data;
}
-const uint8* pdb_get_lanman_passwd (const struct samu *sampass)
+const uint8 *pdb_get_lanman_passwd(const struct samu *sampass)
{
- if (sampass) {
- SMB_ASSERT((!sampass->lm_pw.data)
- || sampass->lm_pw.length == LM_HASH_LEN);
- return ((uint8*)sampass->lm_pw.data);
- }
- else
- return (NULL);
+ SMB_ASSERT((!sampass->lm_pw.data)
+ || sampass->lm_pw.length == LM_HASH_LEN);
+ return (uint8 *)sampass->lm_pw.data;
}
-const uint8* pdb_get_pw_history (const struct samu *sampass, uint32 *current_hist_len)
+const uint8 *pdb_get_pw_history(const struct samu *sampass, uint32 *current_hist_len)
{
- if (sampass) {
- SMB_ASSERT((!sampass->nt_pw_his.data)
- || ((sampass->nt_pw_his.length % PW_HISTORY_ENTRY_LEN) == 0));
- *current_hist_len = sampass->nt_pw_his.length / PW_HISTORY_ENTRY_LEN;
- return ((uint8*)sampass->nt_pw_his.data);
- } else {
- *current_hist_len = 0;
- return (NULL);
- }
+ SMB_ASSERT((!sampass->nt_pw_his.data)
+ || ((sampass->nt_pw_his.length % PW_HISTORY_ENTRY_LEN) == 0));
+ *current_hist_len = sampass->nt_pw_his.length / PW_HISTORY_ENTRY_LEN;
+ return (uint8 *)sampass->nt_pw_his.data;
}
/* Return the plaintext password if known. Most of the time
@@ -169,20 +123,14 @@ const uint8* pdb_get_pw_history (const struct samu *sampass, uint32 *current_his
Used to pass the plaintext to passdb backends that might
want to store more than just the NTLM hashes.
*/
-const char* pdb_get_plaintext_passwd (const struct samu *sampass)
+const char *pdb_get_plaintext_passwd(const struct samu *sampass)
{
- if (sampass) {
- return (sampass->plaintext_pw);
- }
- else
- return (NULL);
+ return sampass->plaintext_pw;
}
+
const DOM_SID *pdb_get_user_sid(const struct samu *sampass)
{
- if (sampass)
- return &sampass->user_sid;
-
- return NULL;
+ return &sampass->user_sid;
}
const DOM_SID *pdb_get_group_sid(struct samu *sampass)
@@ -190,14 +138,7 @@ const DOM_SID *pdb_get_group_sid(struct samu *sampass)
DOM_SID *gsid;
struct passwd *pwd;
- /* sanity check */
-
- if ( !sampass ) {
- return NULL;
- }
-
/* Return the cached group SID if we have that */
-
if ( sampass->group_sid ) {
return sampass->group_sid;
}
@@ -213,10 +154,11 @@ const DOM_SID *pdb_get_group_sid(struct samu *sampass)
be a newly allocated one. We rely on the user's Unix primary gid.
We have no choice but to fail if we can't find it. */
- if ( sampass->unix_pw )
+ if ( sampass->unix_pw ) {
pwd = sampass->unix_pw;
- else
+ } else {
pwd = getpwnam_alloc( sampass, pdb_get_username(sampass) );
+ }
if ( !pwd ) {
DEBUG(0,("pdb_get_group_sid: Failed to find Unix account for %s\n", pdb_get_username(sampass) ));
@@ -264,11 +206,11 @@ const DOM_SID *pdb_get_group_sid(struct samu *sampass)
* @return the flags indicating the members initialised in the struct.
**/
-enum pdb_value_state pdb_get_init_flags (const struct samu *sampass, enum pdb_elements element)
+enum pdb_value_state pdb_get_init_flags(const struct samu *sampass, enum pdb_elements element)
{
enum pdb_value_state ret = PDB_DEFAULT;
- if (!sampass || !sampass->change_flags || !sampass->set_flags)
+ if (!sampass->change_flags || !sampass->set_flags)
return ret;
if (bitmap_query(sampass->set_flags, element)) {
@@ -288,147 +230,103 @@ enum pdb_value_state pdb_get_init_flags (const struct samu *sampass, enum pdb_el
return ret;
}
-const char* pdb_get_username (const struct samu *sampass)
+const char *pdb_get_username(const struct samu *sampass)
{
- if (sampass)
- return (sampass->username);
- else
- return (NULL);
+ return sampass->username;
}
-const char* pdb_get_domain (const struct samu *sampass)
+const char *pdb_get_domain(const struct samu *sampass)
{
- if (sampass)
- return (sampass->domain);
- else
- return (NULL);
+ return sampass->domain;
}
-const char* pdb_get_nt_username (const struct samu *sampass)
+const char *pdb_get_nt_username(const struct samu *sampass)
{
- if (sampass)
- return (sampass->nt_username);
- else
- return (NULL);
+ return sampass->nt_username;
}
-const char* pdb_get_fullname (const struct samu *sampass)
+const char *pdb_get_fullname(const struct samu *sampass)
{
- if (sampass)
- return (sampass->full_name);
- else
- return (NULL);
+ return sampass->full_name;
}
-const char* pdb_get_homedir (const struct samu *sampass)
+const char *pdb_get_homedir(const struct samu *sampass)
{
- if (sampass)
- return (sampass->home_dir);
- else
- return (NULL);
+ return sampass->home_dir;
}
-const char* pdb_get_unix_homedir (const struct samu *sampass)
+const char *pdb_get_unix_homedir(const struct samu *sampass)
{
- if ( sampass && sampass->unix_pw )
- return ( sampass->unix_pw->pw_dir );
-
- return (NULL);
+ if (sampass->unix_pw ) {
+ return sampass->unix_pw->pw_dir;
+ }
+ return NULL;
}
-const char* pdb_get_dir_drive (const struct samu *sampass)
+const char *pdb_get_dir_drive(const struct samu *sampass)
{
- if (sampass)
- return (sampass->dir_drive);
- else
- return (NULL);
+ return sampass->dir_drive;
}
-const char* pdb_get_logon_script (const struct samu *sampass)
+const char *pdb_get_logon_script(const struct samu *sampass)
{
- if (sampass)
- return (sampass->logon_script);
- else
- return (NULL);
+ return sampass->logon_script;
}
-const char* pdb_get_profile_path (const struct samu *sampass)
+const char *pdb_get_profile_path(const struct samu *sampass)
{
- if (sampass)
- return (sampass->profile_path);
- else
- return (NULL);
+ return sampass->profile_path;
}
-const char* pdb_get_acct_desc (const struct samu *sampass)
+const char *pdb_get_acct_desc(const struct samu *sampass)
{
- if (sampass)
- return (sampass->acct_desc);
- else
- return (NULL);
+ return sampass->acct_desc;
}
-const char* pdb_get_workstations (const struct samu *sampass)
+const char *pdb_get_workstations(const struct samu *sampass)
{
- if (sampass)
- return (sampass->workstations);
- else
- return (NULL);
+ return sampass->workstations;
}
-const char* pdb_get_unknown_str (const struct samu *sampass)
+const char *pdb_get_unknown_str(const struct samu *sampass)
{
- if (sampass)
- return (sampass->unknown_str);
- else
- return (NULL);
+ return sampass->unknown_str;
}
-const char* pdb_get_munged_dial (const struct samu *sampass)
+const char *pdb_get_munged_dial(const struct samu *sampass)
{
- if (sampass)
- return (sampass->munged_dial);
- else
- return (NULL);
+ return sampass->munged_dial;
}
uint16 pdb_get_bad_password_count(const struct samu *sampass)
{
- if (sampass)
- return (sampass->bad_password_count);
- else
- return 0;
+ return sampass->bad_password_count;
}
uint16 pdb_get_logon_count(const struct samu *sampass)
{
- if (sampass)
- return (sampass->logon_count);
- else
- return 0;
+ return sampass->logon_count;
}
-uint32 pdb_get_unknown_6 (const struct samu *sampass)
+uint32 pdb_get_unknown_6(const struct samu *sampass)
{
- if (sampass)
- return (sampass->unknown_6);
- else
- return (-1);
+ return sampass->unknown_6;
}
-void *pdb_get_backend_private_data (const struct samu *sampass, const struct pdb_methods *my_methods)
+void *pdb_get_backend_private_data(const struct samu *sampass, const struct pdb_methods *my_methods)
{
- if (sampass && my_methods == sampass->backend_private_methods)
+ if (my_methods == sampass->backend_private_methods) {
return sampass->backend_private_data;
- else
+ } else {
return NULL;
+ }
}
/*********************************************************************
Collection of set...() functions for struct samu.
********************************************************************/
-BOOL pdb_set_acct_ctrl (struct samu *sampass, uint32 acct_ctrl, enum pdb_value_state flag)
+BOOL pdb_set_acct_ctrl(struct samu *sampass, uint32 acct_ctrl, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -438,7 +336,7 @@ BOOL pdb_set_acct_ctrl (struct samu *sampass, uint32 acct_ctrl, enum pdb_value_s
return pdb_set_init_flags(sampass, PDB_ACCTCTRL, flag);
}
-BOOL pdb_set_logon_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_logon_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -448,7 +346,7 @@ BOOL pdb_set_logon_time (struct samu *sampass, time_t mytime, enum pdb_value_sta
return pdb_set_init_flags(sampass, PDB_LOGONTIME, flag);
}
-BOOL pdb_set_logoff_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_logoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -458,7 +356,7 @@ BOOL pdb_set_logoff_time (struct samu *sampass, time_t mytime, enum pdb_value_st
return pdb_set_init_flags(sampass, PDB_LOGOFFTIME, flag);
}
-BOOL pdb_set_kickoff_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_kickoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -468,8 +366,7 @@ BOOL pdb_set_kickoff_time (struct samu *sampass, time_t mytime, enum pdb_value_s
return pdb_set_init_flags(sampass, PDB_KICKOFFTIME, flag);
}
-BOOL pdb_set_bad_password_time (struct samu *sampass, time_t mytime,
- enum pdb_value_state flag)
+BOOL pdb_set_bad_password_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -479,7 +376,7 @@ BOOL pdb_set_bad_password_time (struct samu *sampass, time_t mytime,
return pdb_set_init_flags(sampass, PDB_BAD_PASSWORD_TIME, flag);
}
-BOOL pdb_set_pass_can_change_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_pass_can_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -489,7 +386,7 @@ BOOL pdb_set_pass_can_change_time (struct samu *sampass, time_t mytime, enum pdb
return pdb_set_init_flags(sampass, PDB_CANCHANGETIME, flag);
}
-BOOL pdb_set_pass_must_change_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_pass_must_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -499,7 +396,7 @@ BOOL pdb_set_pass_must_change_time (struct samu *sampass, time_t mytime, enum pd
return pdb_set_init_flags(sampass, PDB_MUSTCHANGETIME, flag);
}
-BOOL pdb_set_pass_last_set_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_pass_last_set_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -509,7 +406,7 @@ BOOL pdb_set_pass_last_set_time (struct samu *sampass, time_t mytime, enum pdb_v
return pdb_set_init_flags(sampass, PDB_PASSLASTSET, flag);
}
-BOOL pdb_set_hours_len (struct samu *sampass, uint32 len, enum pdb_value_state flag)
+BOOL pdb_set_hours_len(struct samu *sampass, uint32 len, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -519,7 +416,7 @@ BOOL pdb_set_hours_len (struct samu *sampass, uint32 len, enum pdb_value_state f
return pdb_set_init_flags(sampass, PDB_HOURSLEN, flag);
}
-BOOL pdb_set_logon_divs (struct samu *sampass, uint16 hours, enum pdb_value_state flag)
+BOOL pdb_set_logon_divs(struct samu *sampass, uint16 hours, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -536,7 +433,7 @@ BOOL pdb_set_logon_divs (struct samu *sampass, uint16 hours, enum pdb_value_stat
* this flag is only added.
**/
-BOOL pdb_set_init_flags (struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag)
+BOOL pdb_set_init_flags(struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag)
{
if (!sampass || !sampass)
return False;
@@ -598,7 +495,7 @@ BOOL pdb_set_init_flags (struct samu *sampass, enum pdb_elements element, enum p
return True;
}
-BOOL pdb_set_user_sid (struct samu *sampass, const DOM_SID *u_sid, enum pdb_value_state flag)
+BOOL pdb_set_user_sid(struct samu *sampass, const DOM_SID *u_sid, enum pdb_value_state flag)
{
if (!sampass || !u_sid)
return False;
@@ -611,7 +508,7 @@ BOOL pdb_set_user_sid (struct samu *sampass, const DOM_SID *u_sid, enum pdb_valu
return pdb_set_init_flags(sampass, PDB_USERSID, flag);
}
-BOOL pdb_set_user_sid_from_string (struct samu *sampass, fstring u_sid, enum pdb_value_state flag)
+BOOL pdb_set_user_sid_from_string(struct samu *sampass, fstring u_sid, enum pdb_value_state flag)
{
DOM_SID new_sid;
@@ -642,7 +539,7 @@ BOOL pdb_set_user_sid_from_string (struct samu *sampass, fstring u_sid, enum pdb
have to allow the explicitly setting of a group SID here.
********************************************************************/
-BOOL pdb_set_group_sid (struct samu *sampass, const DOM_SID *g_sid, enum pdb_value_state flag)
+BOOL pdb_set_group_sid(struct samu *sampass, const DOM_SID *g_sid, enum pdb_value_state flag)
{
gid_t gid;
@@ -808,7 +705,7 @@ BOOL pdb_set_logon_script(struct samu *sampass, const char *logon_script, enum p
Set the user's profile path.
********************************************************************/
-BOOL pdb_set_profile_path (struct samu *sampass, const char *profile_path, enum pdb_value_state flag)
+BOOL pdb_set_profile_path(struct samu *sampass, const char *profile_path, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -835,7 +732,7 @@ BOOL pdb_set_profile_path (struct samu *sampass, const char *profile_path, enum
Set the user's directory drive.
********************************************************************/
-BOOL pdb_set_dir_drive (struct samu *sampass, const char *dir_drive, enum pdb_value_state flag)
+BOOL pdb_set_dir_drive(struct samu *sampass, const char *dir_drive, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -862,7 +759,7 @@ BOOL pdb_set_dir_drive (struct samu *sampass, const char *dir_drive, enum pdb_va
Set the user's home directory.
********************************************************************/
-BOOL pdb_set_homedir (struct samu *sampass, const char *home_dir, enum pdb_value_state flag)
+BOOL pdb_set_homedir(struct samu *sampass, const char *home_dir, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -889,7 +786,7 @@ BOOL pdb_set_homedir (struct samu *sampass, const char *home_dir, enum pdb_value
Set the user's account description.
********************************************************************/
-BOOL pdb_set_acct_desc (struct samu *sampass, const char *acct_desc, enum pdb_value_state flag)
+BOOL pdb_set_acct_desc(struct samu *sampass, const char *acct_desc, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -913,7 +810,7 @@ BOOL pdb_set_acct_desc (struct samu *sampass, const char *acct_desc, enum pdb_va
Set the user's workstation allowed list.
********************************************************************/
-BOOL pdb_set_workstations (struct samu *sampass, const char *workstations, enum pdb_value_state flag)
+BOOL pdb_set_workstations(struct samu *sampass, const char *workstations, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -940,7 +837,7 @@ BOOL pdb_set_workstations (struct samu *sampass, const char *workstations, enum
Set the user's 'unknown_str', whatever the heck this actually is...
********************************************************************/
-BOOL pdb_set_unknown_str (struct samu *sampass, const char *unknown_str, enum pdb_value_state flag)
+BOOL pdb_set_unknown_str(struct samu *sampass, const char *unknown_str, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -964,7 +861,7 @@ BOOL pdb_set_unknown_str (struct samu *sampass, const char *unknown_str, enum pd
Set the user's dial string.
********************************************************************/
-BOOL pdb_set_munged_dial (struct samu *sampass, const char *munged_dial, enum pdb_value_state flag)
+BOOL pdb_set_munged_dial(struct samu *sampass, const char *munged_dial, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -988,7 +885,7 @@ BOOL pdb_set_munged_dial (struct samu *sampass, const char *munged_dial, enum pd
Set the user's NT hash.
********************************************************************/
-BOOL pdb_set_nt_passwd (struct samu *sampass, const uint8 pwd[NT_HASH_LEN], enum pdb_value_state flag)
+BOOL pdb_set_nt_passwd(struct samu *sampass, const uint8 pwd[NT_HASH_LEN], enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -1009,7 +906,7 @@ BOOL pdb_set_nt_passwd (struct samu *sampass, const uint8 pwd[NT_HASH_LEN], enum
Set the user's LM hash.
********************************************************************/
-BOOL pdb_set_lanman_passwd (struct samu *sampass, const uint8 pwd[LM_HASH_LEN], enum pdb_value_state flag)
+BOOL pdb_set_lanman_passwd(struct samu *sampass, const uint8 pwd[LM_HASH_LEN], enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -1034,7 +931,7 @@ BOOL pdb_set_lanman_passwd (struct samu *sampass, const uint8 pwd[LM_HASH_LEN],
in pwd.
********************************************************************/
-BOOL pdb_set_pw_history (struct samu *sampass, const uint8 *pwd, uint32 historyLen, enum pdb_value_state flag)
+BOOL pdb_set_pw_history(struct samu *sampass, const uint8 *pwd, uint32 historyLen, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -1058,7 +955,7 @@ BOOL pdb_set_pw_history (struct samu *sampass, const uint8 *pwd, uint32 historyL
below)
********************************************************************/
-BOOL pdb_set_plaintext_pw_only (struct samu *sampass, const char *password, enum pdb_value_state flag)
+BOOL pdb_set_plaintext_pw_only(struct samu *sampass, const char *password, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -1101,7 +998,7 @@ BOOL pdb_set_logon_count(struct samu *sampass, uint16 logon_count, enum pdb_valu
return pdb_set_init_flags(sampass, PDB_LOGON_COUNT, flag);
}
-BOOL pdb_set_unknown_6 (struct samu *sampass, uint32 unkn, enum pdb_value_state flag)
+BOOL pdb_set_unknown_6(struct samu *sampass, uint32 unkn, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -1111,7 +1008,7 @@ BOOL pdb_set_unknown_6 (struct samu *sampass, uint32 unkn, enum pdb_value_state
return pdb_set_init_flags(sampass, PDB_UNKNOWN6, flag);
}
-BOOL pdb_set_hours (struct samu *sampass, const uint8 *hours, enum pdb_value_state flag)
+BOOL pdb_set_hours(struct samu *sampass, const uint8 *hours, enum pdb_value_state flag)
{
if (!sampass)
return False;
@@ -1126,7 +1023,7 @@ BOOL pdb_set_hours (struct samu *sampass, const uint8 *hours, enum pdb_value_sta
return pdb_set_init_flags(sampass, PDB_HOURS, flag);
}
-BOOL pdb_set_backend_private_data (struct samu *sampass, void *private_data,
+BOOL pdb_set_backend_private_data(struct samu *sampass, void *private_data,
void (*free_fn)(void **),
const struct pdb_methods *my_methods,
enum pdb_value_state flag)
@@ -1155,7 +1052,7 @@ BOOL pdb_set_backend_private_data (struct samu *sampass, void *private_data,
password change.
********************************************************************/
-BOOL pdb_set_pass_changed_now (struct samu *sampass)
+BOOL pdb_set_pass_changed_now(struct samu *sampass)
{
uint32 expire;
uint32 min_age;
@@ -1195,7 +1092,7 @@ BOOL pdb_set_pass_changed_now (struct samu *sampass)
Also sets the last change time to NOW.
********************************************************************/
-BOOL pdb_set_plaintext_passwd (struct samu *sampass, const char *plaintext)
+BOOL pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext)
{
uchar new_lanman_p16[LM_HASH_LEN];
uchar new_nt_p16[NT_HASH_LEN];
@@ -1294,7 +1191,7 @@ BOOL pdb_set_plaintext_passwd (struct samu *sampass, const char *plaintext)
}
/* check for any PDB_SET/CHANGED field and fill the appropriate mask bit */
-uint32 pdb_build_fields_present (struct samu *sampass)
+uint32 pdb_build_fields_present(struct samu *sampass)
{
/* value set to all for testing */
return 0x00ffffff;
diff --git a/source/passdb/pdb_interface.c b/source/passdb/pdb_interface.c
index 393b60516cc..94adebe2327 100644
--- a/source/passdb/pdb_interface.c
+++ b/source/passdb/pdb_interface.c
@@ -37,7 +37,9 @@ static struct pdb_init_function_entry *backends = NULL;
static void lazy_initialize_passdb(void)
{
static BOOL initialized = False;
- if(initialized)return;
+ if(initialized) {
+ return;
+ }
static_init_pdb;
initialized = True;
}
@@ -201,13 +203,19 @@ static struct pdb_methods *pdb_get_methods_reload( BOOL reload )
if ( pdb && reload ) {
pdb->free_private_data( &(pdb->private_data) );
if ( !NT_STATUS_IS_OK( make_pdb_method_name( &pdb, lp_passdb_backend() ) ) ) {
- return NULL;
+ pstring msg;
+ slprintf(msg, sizeof(msg)-1, "pdb_get_methods_reload: failed to get pdb methods for backend %s\n",
+ lp_passdb_backend() );
+ smb_panic(msg);
}
}
if ( !pdb ) {
if ( !NT_STATUS_IS_OK( make_pdb_method_name( &pdb, lp_passdb_backend() ) ) ) {
- return NULL;
+ pstring msg;
+ slprintf(msg, sizeof(msg)-1, "pdb_get_methods_reload: failed to get pdb methods for backend %s\n",
+ lp_passdb_backend() );
+ smb_panic(msg);
}
}
@@ -226,22 +234,12 @@ static struct pdb_methods *pdb_get_methods(void)
BOOL pdb_setsampwent(BOOL update, uint16 acb_mask)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->setsampwent(pdb, update, acb_mask));
}
void pdb_endsampwent(void)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return;
- }
-
pdb->endsampwent(pdb);
}
@@ -249,16 +247,10 @@ BOOL pdb_getsampwent(struct samu *user)
{
struct pdb_methods *pdb = pdb_get_methods();
- if ( !pdb ) {
- return False;
- }
-
if ( !NT_STATUS_IS_OK(pdb->getsampwent(pdb, user) ) ) {
return False;
}
-
pdb_force_pw_initialization( user );
-
return True;
}
@@ -266,10 +258,6 @@ BOOL pdb_getsampwnam(struct samu *sam_acct, const char *username)
{
struct pdb_methods *pdb = pdb_get_methods();
- if ( !pdb ) {
- return False;
- }
-
if (!NT_STATUS_IS_OK(pdb->getsampwnam(pdb, sam_acct, username))) {
return False;
}
@@ -280,8 +268,14 @@ BOOL pdb_getsampwnam(struct samu *sam_acct, const char *username)
pdb_force_pw_initialization( sam_acct );
- if ( (csamuser = samu_new( NULL )) != NULL ) {
- pdb_copy_sam_account(csamuser, sam_acct);
+ csamuser = samu_new( NULL );
+ if (!csamuser) {
+ return False;
+ }
+
+ if (!pdb_copy_sam_account(csamuser, sam_acct)) {
+ TALLOC_FREE(csamuser);
+ return False;
}
return True;
@@ -314,13 +308,9 @@ BOOL guest_user_info( struct samu *user )
BOOL pdb_getsampwsid(struct samu *sam_acct, const DOM_SID *sid)
{
- struct pdb_methods *pdb;
+ struct pdb_methods *pdb = pdb_get_methods();
uint32 rid;
- if ( !(pdb = pdb_get_methods()) ) {
- return False;
- }
-
/* hard code the Guest RID of 501 */
if ( !sid_peek_check_rid( get_global_sam_sid(), sid, &rid ) )
@@ -410,11 +400,6 @@ NTSTATUS pdb_create_user(TALLOC_CTX *mem_ctx, const char *name, uint32 flags,
uint32 *rid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->create_user(pdb, mem_ctx, name, flags, rid);
}
@@ -472,10 +457,6 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct)
struct pdb_methods *pdb = pdb_get_methods();
uid_t uid = -1;
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
/* sanity check to make sure we don't delete root */
if ( !sid_to_uid( pdb_get_user_sid(sam_acct), &uid ) ) {
@@ -492,11 +473,6 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct)
NTSTATUS pdb_add_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->add_sam_account(pdb, sam_acct);
}
@@ -504,10 +480,6 @@ NTSTATUS pdb_update_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods();
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
if (csamuser != NULL) {
TALLOC_FREE(csamuser);
csamuser = NULL;
@@ -520,10 +492,6 @@ NTSTATUS pdb_delete_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods();
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
if (csamuser != NULL) {
TALLOC_FREE(csamuser);
csamuser = NULL;
@@ -537,10 +505,6 @@ NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname)
struct pdb_methods *pdb = pdb_get_methods();
uid_t uid;
- if ( !pdb ) {
- return NT_STATUS_NOT_IMPLEMENTED;
- }
-
if (csamuser != NULL) {
TALLOC_FREE(csamuser);
csamuser = NULL;
@@ -562,44 +526,24 @@ NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname)
NTSTATUS pdb_update_login_attempts(struct samu *sam_acct, BOOL success)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_NOT_IMPLEMENTED;
- }
-
return pdb->update_login_attempts(pdb, sam_acct, success);
}
BOOL pdb_getgrsid(GROUP_MAP *map, DOM_SID sid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->getgrsid(pdb, map, sid));
}
BOOL pdb_getgrgid(GROUP_MAP *map, gid_t gid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->getgrgid(pdb, map, gid));
}
BOOL pdb_getgrnam(GROUP_MAP *map, const char *name)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->getgrnam(pdb, map, name));
}
@@ -645,11 +589,6 @@ NTSTATUS pdb_create_dom_group(TALLOC_CTX *mem_ctx, const char *name,
uint32 *rid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->create_dom_group(pdb, mem_ctx, name, rid);
}
@@ -704,44 +643,24 @@ static NTSTATUS pdb_default_delete_dom_group(struct pdb_methods *methods,
NTSTATUS pdb_delete_dom_group(TALLOC_CTX *mem_ctx, uint32 rid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->delete_dom_group(pdb, mem_ctx, rid);
}
NTSTATUS pdb_add_group_mapping_entry(GROUP_MAP *map)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->add_group_mapping_entry(pdb, map);
}
NTSTATUS pdb_update_group_mapping_entry(GROUP_MAP *map)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->update_group_mapping_entry(pdb, map);
}
NTSTATUS pdb_delete_group_mapping_entry(DOM_SID sid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->delete_group_mapping_entry(pdb, sid);
}
@@ -749,11 +668,6 @@ BOOL pdb_enum_group_mapping(const DOM_SID *sid, enum SID_NAME_USE sid_name_use,
size_t *p_num_entries, BOOL unix_only)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb-> enum_group_mapping(pdb, sid, sid_name_use,
pp_rmap, p_num_entries, unix_only));
}
@@ -766,10 +680,6 @@ NTSTATUS pdb_enum_group_members(TALLOC_CTX *mem_ctx,
struct pdb_methods *pdb = pdb_get_methods();
NTSTATUS result;
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
result = pdb->enum_group_members(pdb, mem_ctx,
sid, pp_member_rids, p_num_members);
@@ -796,11 +706,6 @@ NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, struct samu *user,
size_t *p_num_groups)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->enum_group_memberships(
pdb, mem_ctx, user,
pp_sids, pp_gids, p_num_groups);
@@ -829,11 +734,6 @@ static NTSTATUS pdb_default_set_unix_primary_group(struct pdb_methods *methods,
NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, struct samu *user)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->set_unix_primary_group(pdb, mem_ctx, user);
}
@@ -923,11 +823,6 @@ NTSTATUS pdb_add_groupmem(TALLOC_CTX *mem_ctx, uint32 group_rid,
uint32 member_rid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->add_groupmem(pdb, mem_ctx, group_rid, member_rid);
}
@@ -990,44 +885,24 @@ NTSTATUS pdb_del_groupmem(TALLOC_CTX *mem_ctx, uint32 group_rid,
uint32 member_rid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->del_groupmem(pdb, mem_ctx, group_rid, member_rid);
}
BOOL pdb_find_alias(const char *name, DOM_SID *sid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->find_alias(pdb, name, sid));
}
NTSTATUS pdb_create_alias(const char *name, uint32 *rid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_NOT_IMPLEMENTED;
- }
-
return pdb->create_alias(pdb, name, rid);
}
BOOL pdb_delete_alias(const DOM_SID *sid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->delete_alias(pdb, sid));
}
@@ -1035,44 +910,24 @@ BOOL pdb_delete_alias(const DOM_SID *sid)
BOOL pdb_get_aliasinfo(const DOM_SID *sid, struct acct_info *info)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->get_aliasinfo(pdb, sid, info));
}
BOOL pdb_set_aliasinfo(const DOM_SID *sid, struct acct_info *info)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->set_aliasinfo(pdb, sid, info));
}
NTSTATUS pdb_add_aliasmem(const DOM_SID *alias, const DOM_SID *member)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->add_aliasmem(pdb, alias, member);
}
NTSTATUS pdb_del_aliasmem(const DOM_SID *alias, const DOM_SID *member)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
return pdb->del_aliasmem(pdb, alias, member);
}
@@ -1080,13 +935,7 @@ NTSTATUS pdb_enum_aliasmem(const DOM_SID *alias,
DOM_SID **pp_members, size_t *p_num_members)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- return pdb->enum_aliasmem(pdb, alias,
- pp_members, p_num_members);
+ return pdb->enum_aliasmem(pdb, alias, pp_members, p_num_members);
}
NTSTATUS pdb_enum_alias_memberships(TALLOC_CTX *mem_ctx,
@@ -1096,11 +945,6 @@ NTSTATUS pdb_enum_alias_memberships(TALLOC_CTX *mem_ctx,
size_t *p_num_alias_rids)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_NOT_IMPLEMENTED;
- }
-
return pdb->enum_alias_memberships(pdb, mem_ctx,
domain_sid,
members, num_members,
@@ -1115,11 +959,6 @@ NTSTATUS pdb_lookup_rids(const DOM_SID *domain_sid,
uint32 *attrs)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_NOT_IMPLEMENTED;
- }
-
return pdb->lookup_rids(pdb, domain_sid,
num_rids, rids, names, attrs);
}
@@ -1131,11 +970,6 @@ NTSTATUS pdb_lookup_names(const DOM_SID *domain_sid,
uint32 *attrs)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return NT_STATUS_NOT_IMPLEMENTED;
- }
-
return pdb->lookup_names(pdb, domain_sid,
num_names, names, rids, attrs);
}
@@ -1143,55 +977,30 @@ NTSTATUS pdb_lookup_names(const DOM_SID *domain_sid,
BOOL pdb_get_account_policy(int policy_index, uint32 *value)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->get_account_policy(pdb, policy_index, value));
}
BOOL pdb_set_account_policy(int policy_index, uint32 value)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->set_account_policy(pdb, policy_index, value));
}
BOOL pdb_get_seq_num(time_t *seq_num)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return NT_STATUS_IS_OK(pdb->get_seq_num(pdb, seq_num));
}
BOOL pdb_uid_to_rid(uid_t uid, uint32 *rid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return pdb->uid_to_rid(pdb, uid, rid);
}
BOOL pdb_gid_to_sid(gid_t gid, DOM_SID *sid)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return pdb->gid_to_sid(pdb, gid, sid);
}
@@ -1199,22 +1008,12 @@ BOOL pdb_sid_to_id(const DOM_SID *sid, union unid_t *id,
enum SID_NAME_USE *type)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return pdb->sid_to_id(pdb, sid, id, type);
}
BOOL pdb_rid_algorithm(void)
{
struct pdb_methods *pdb = pdb_get_methods();
-
- if ( !pdb ) {
- return False;
- }
-
return pdb->rid_algorithm(pdb);
}
@@ -1234,10 +1033,6 @@ BOOL pdb_new_rid(uint32 *rid)
int i;
TALLOC_CTX *ctx;
- if ( !pdb ) {
- return False;
- }
-
if (pdb_rid_algorithm()) {
DEBUG(0, ("Trying to allocate a RID when algorithmic RIDs "
"are active\n"));
@@ -2079,10 +1874,10 @@ struct pdb_search *pdb_search_users(uint32 acct_flags)
struct pdb_methods *pdb = pdb_get_methods();
struct pdb_search *result;
- if (pdb == NULL) return NULL;
-
result = pdb_search_init(PDB_USER_SEARCH);
- if (result == NULL) return NULL;
+ if (result == NULL) {
+ return NULL;
+ }
if (!pdb->search_users(pdb, result, acct_flags)) {
talloc_destroy(result->mem_ctx);
@@ -2096,10 +1891,10 @@ struct pdb_search *pdb_search_groups(void)
struct pdb_methods *pdb = pdb_get_methods();
struct pdb_search *result;
- if (pdb == NULL) return NULL;
-
result = pdb_search_init(PDB_GROUP_SEARCH);
- if (result == NULL) return NULL;
+ if (result == NULL) {
+ return NULL;
+ }
if (!pdb->search_groups(pdb, result)) {
talloc_destroy(result->mem_ctx);
diff --git a/source/passdb/secrets.c b/source/passdb/secrets.c
index ee7c441fcfc..04d6da2814a 100644
--- a/source/passdb/secrets.c
+++ b/source/passdb/secrets.c
@@ -1044,8 +1044,6 @@ BOOL secrets_restore_schannel_session_info(TALLOC_CTX *mem_ctx,
return False;
}
- tdb_close(tdb_sc);
-
pdc = TALLOC_ZERO_P(mem_ctx, struct dcinfo);
/* Retrieve the record. */
@@ -1063,6 +1061,7 @@ BOOL secrets_restore_schannel_session_info(TALLOC_CTX *mem_ctx,
if (ret == -1 || l1 != 8 || l2 != 8 || l3 != 8 || l4 != 16 || l5 != 16) {
/* Bad record - delete it. */
tdb_delete_bystring(tdb_sc, keystr);
+ tdb_close(tdb_sc);
TALLOC_FREE(keystr);
TALLOC_FREE(pdc);
SAFE_FREE(pseed_chal);
@@ -1074,6 +1073,8 @@ BOOL secrets_restore_schannel_session_info(TALLOC_CTX *mem_ctx,
return False;
}
+ tdb_close(tdb_sc);
+
memcpy(pdc->seed_chal.data, pseed_chal, 8);
memcpy(pdc->clnt_chal.data, pclnt_chal, 8);
memcpy(pdc->srv_chal.data, psrv_chal, 8);
diff --git a/source/printing/lpq_parse.c b/source/printing/lpq_parse.c
index 7e81b5187c9..100585637ae 100644
--- a/source/printing/lpq_parse.c
+++ b/source/printing/lpq_parse.c
@@ -25,50 +25,62 @@ static const char *Months[13] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
/*******************************************************************
-process time fields
+ Process time fields
********************************************************************/
+
static time_t EntryTime(fstring tok[], int ptr, int count, int minimum)
{
- time_t jobtime,jobtime1;
-
- jobtime = time(NULL); /* default case: take current time */
- if (count >= minimum) {
- struct tm *t;
- int i, day, hour, min, sec;
- char *c;
-
- for (i=0; i<13; i++) if (!strncmp(tok[ptr], Months[i],3)) break; /* Find month */
- if (i<12) {
- t = localtime(&jobtime);
- day = atoi(tok[ptr+1]);
- c=(char *)(tok[ptr+2]);
- *(c+2)=0;
- hour = atoi(c);
- *(c+5)=0;
- min = atoi(c+3);
- if(*(c+6) != 0)sec = atoi(c+6);
- else sec=0;
-
- if ((t->tm_mon < i)||
- ((t->tm_mon == i)&&
- ((t->tm_mday < day)||
- ((t->tm_mday == day)&&
- (t->tm_hour*60+t->tm_min < hour*60+min)))))
- t->tm_year--; /* last year's print job */
-
- t->tm_mon = i;
- t->tm_mday = day;
- t->tm_hour = hour;
- t->tm_min = min;
- t->tm_sec = sec;
- jobtime1 = mktime(t);
- if (jobtime1 != (time_t)-1)
- jobtime = jobtime1;
- }
- }
- return jobtime;
-}
+ time_t jobtime,jobtime1;
+
+ jobtime = time(NULL); /* default case: take current time */
+ if (count >= minimum) {
+ struct tm *t;
+ int i, day, hour, min, sec;
+ char *c;
+
+ for (i=0; i<13; i++) {
+ if (!strncmp(tok[ptr], Months[i],3)) {
+ break; /* Find month */
+ }
+ }
+ if (i<12) {
+ t = localtime(&jobtime);
+ if (!t) {
+ return (time_t)-1;
+ }
+ day = atoi(tok[ptr+1]);
+ c=(char *)(tok[ptr+2]);
+ *(c+2)=0;
+ hour = atoi(c);
+ *(c+5)=0;
+ min = atoi(c+3);
+ if(*(c+6) != 0) {
+ sec = atoi(c+6);
+ } else {
+ sec=0;
+ }
+
+ if ((t->tm_mon < i)|| ((t->tm_mon == i)&&
+ ((t->tm_mday < day)||
+ ((t->tm_mday == day)&&
+ (t->tm_hour*60+t->tm_min < hour*60+min))))) {
+ t->tm_year--; /* last year's print job */
+ }
+
+ t->tm_mon = i;
+ t->tm_mday = day;
+ t->tm_hour = hour;
+ t->tm_min = min;
+ t->tm_sec = sec;
+ jobtime1 = mktime(t);
+ if (jobtime1 != (time_t)-1) {
+ jobtime = jobtime1;
+ }
+ }
+ }
+ return jobtime;
+}
/****************************************************************************
parse a lpq line
@@ -90,6 +102,7 @@ Rank Pri Owner Job Files Total Size
Modified to handle file names with spaces, like the parse_lpq_lprng code
further below.
****************************************************************************/
+
static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
{
#ifdef OSF1
@@ -111,63 +124,67 @@ static BOOL parse_lpq_bsd(char *line,print_queue_struct *buf,BOOL first)
#define MAXTOK 128
#endif /* OSF1 */
- char *tok[MAXTOK];
- int count = 0;
- pstring line2;
+ char *tok[MAXTOK];
+ int count = 0;
+ pstring line2;
- pstrcpy(line2,line);
+ pstrcpy(line2,line);
#ifdef OSF1
- {
- size_t length;
- length = strlen(line2);
- if (line2[length-3] == ':')
- return(False);
- }
+ {
+ size_t length;
+ length = strlen(line2);
+ if (line2[length-3] == ':') {
+ return False;
+ }
+ }
#endif /* OSF1 */
- /* FIXME: Use next_token rather than strtok! */
- tok[0] = strtok(line2," \t");
- count++;
-
- while (((tok[count] = strtok(NULL," \t")) != NULL) && (count < MAXTOK)) {
- count++;
- }
-
- /* we must get at least NTOK tokens */
- if (count < NTOK)
- return(False);
-
- /* the Job and Total columns must be integer */
- if (!isdigit((int)*tok[JOBTOK]) || !isdigit((int)*tok[TOTALTOK])) return(False);
-
- buf->job = atoi(tok[JOBTOK]);
- buf->size = atoi(tok[TOTALTOK]);
- buf->status = strequal(tok[RANKTOK],"active")?LPQ_PRINTING:LPQ_QUEUED;
- buf->time = time(NULL);
- fstrcpy(buf->fs_user,tok[USERTOK]);
- fstrcpy(buf->fs_file,tok[FILETOK]);
-
- if ((FILETOK + 1) != TOTALTOK) {
- int i;
-
- for (i = (FILETOK + 1); i < TOTALTOK; i++) {
- /* FIXME: Using fstrcat rather than other means is a bit
- * inefficient; this might be a problem for enormous queues with
- * many fields. */
- fstrcat(buf->fs_file, " ");
- fstrcat(buf->fs_file, tok[i]);
- }
- /* Ensure null termination. */
- fstrterminate(buf->fs_file);
- }
+ /* FIXME: Use next_token rather than strtok! */
+ tok[0] = strtok(line2," \t");
+ count++;
+
+ while ((count < MAXTOK) && ((tok[count] = strtok(NULL," \t")) != NULL)) {
+ count++;
+ }
+
+ /* we must get at least NTOK tokens */
+ if (count < NTOK) {
+ return False;
+ }
+
+ /* the Job and Total columns must be integer */
+ if (!isdigit((int)*tok[JOBTOK]) || !isdigit((int)*tok[TOTALTOK])) {
+ return False;
+ }
+
+ buf->job = atoi(tok[JOBTOK]);
+ buf->size = atoi(tok[TOTALTOK]);
+ buf->status = strequal(tok[RANKTOK],"active")?LPQ_PRINTING:LPQ_QUEUED;
+ buf->time = time(NULL);
+ fstrcpy(buf->fs_user,tok[USERTOK]);
+ fstrcpy(buf->fs_file,tok[FILETOK]);
+
+ if ((FILETOK + 1) != TOTALTOK) {
+ int i;
+
+ for (i = (FILETOK + 1); i < TOTALTOK; i++) {
+ /* FIXME: Using fstrcat rather than other means is a bit
+ * inefficient; this might be a problem for enormous queues with
+ * many fields. */
+ fstrcat(buf->fs_file, " ");
+ fstrcat(buf->fs_file, tok[i]);
+ }
+ /* Ensure null termination. */
+ fstrterminate(buf->fs_file);
+ }
#ifdef PRIOTOK
- buf->priority = atoi(tok[PRIOTOK]);
+ buf->priority = atoi(tok[PRIOTOK]);
#else
- buf->priority = 1;
+ buf->priority = 1;
#endif
- return(True);
+ return True;
}
/*
@@ -190,35 +207,39 @@ With lprng 3.16 The lpq time looks like
static time_t LPRng_time(char *time_string)
{
time_t jobtime;
- struct tm t;
+ struct tm *t;
jobtime = time(NULL); /* default case: take current time */
- t = *localtime(&jobtime);
+ t = localtime(&jobtime);
+ if (!t) {
+ return (time_t)-1;
+ }
if ( atoi(time_string) < 24 ){
- t.tm_hour = atoi(time_string);
- t.tm_min = atoi(time_string+3);
- t.tm_sec = atoi(time_string+6);
+ t->tm_hour = atoi(time_string);
+ t->tm_min = atoi(time_string+3);
+ t->tm_sec = atoi(time_string+6);
} else {
- t.tm_year = atoi(time_string)-1900;
- t.tm_mon = atoi(time_string+5)-1;
- t.tm_mday = atoi(time_string+8);
- t.tm_hour = atoi(time_string+11);
- t.tm_min = atoi(time_string+14);
- t.tm_sec = atoi(time_string+17);
+ t->tm_year = atoi(time_string)-1900;
+ t->tm_mon = atoi(time_string+5)-1;
+ t->tm_mday = atoi(time_string+8);
+ t->tm_hour = atoi(time_string+11);
+ t->tm_min = atoi(time_string+14);
+ t->tm_sec = atoi(time_string+17);
}
- jobtime = mktime(&t);
+ jobtime = mktime(t);
return jobtime;
}
-
/****************************************************************************
parse a lprng lpq line
<allan@umich.edu> June 30, 1998.
Re-wrote this to handle file names with spaces, multiple file names on one
lpq line, etc;
+
****************************************************************************/
+
static BOOL parse_lpq_lprng(char *line,print_queue_struct *buf,BOOL first)
{
#define LPRNG_RANKTOK 0
@@ -231,72 +252,71 @@ static BOOL parse_lpq_lprng(char *line,print_queue_struct *buf,BOOL first)
#define LPRNG_NTOK 7
#define LPRNG_MAXTOK 128 /* PFMA just to keep us from running away. */
- fstring tokarr[LPRNG_MAXTOK];
- const char *cptr;
- char *ptr;
- int num_tok = 0;
+ fstring tokarr[LPRNG_MAXTOK];
+ const char *cptr;
+ char *ptr;
+ int num_tok = 0;
- cptr = line;
- while(next_token( &cptr, tokarr[num_tok], " \t", sizeof(fstring)) && (num_tok < LPRNG_MAXTOK))
- num_tok++;
+ cptr = line;
+ while((num_tok < LPRNG_MAXTOK) && next_token( &cptr, tokarr[num_tok], " \t", sizeof(fstring))) {
+ num_tok++;
+ }
- /* We must get at least LPRNG_NTOK tokens. */
- if (num_tok < LPRNG_NTOK) {
- return(False);
- }
+ /* We must get at least LPRNG_NTOK tokens. */
+ if (num_tok < LPRNG_NTOK) {
+ return False;
+ }
- if (!isdigit((int)*tokarr[LPRNG_JOBTOK]) || !isdigit((int)*tokarr[LPRNG_TOTALTOK])) {
- return(False);
- }
+ if (!isdigit((int)*tokarr[LPRNG_JOBTOK]) || !isdigit((int)*tokarr[LPRNG_TOTALTOK])) {
+ return False;
+ }
- buf->job = atoi(tokarr[LPRNG_JOBTOK]);
- buf->size = atoi(tokarr[LPRNG_TOTALTOK]);
+ buf->job = atoi(tokarr[LPRNG_JOBTOK]);
+ buf->size = atoi(tokarr[LPRNG_TOTALTOK]);
- if (strequal(tokarr[LPRNG_RANKTOK],"active")) {
- buf->status = LPQ_PRINTING;
- } else if (strequal(tokarr[LPRNG_RANKTOK],"done")) {
- buf->status = LPQ_PRINTED;
- } else if (isdigit((int)*tokarr[LPRNG_RANKTOK])) {
- buf->status = LPQ_QUEUED;
- } else {
- buf->status = LPQ_PAUSED;
- }
+ if (strequal(tokarr[LPRNG_RANKTOK],"active")) {
+ buf->status = LPQ_PRINTING;
+ } else if (strequal(tokarr[LPRNG_RANKTOK],"done")) {
+ buf->status = LPQ_PRINTED;
+ } else if (isdigit((int)*tokarr[LPRNG_RANKTOK])) {
+ buf->status = LPQ_QUEUED;
+ } else {
+ buf->status = LPQ_PAUSED;
+ }
- buf->priority = *tokarr[LPRNG_PRIOTOK] -'A';
+ buf->priority = *tokarr[LPRNG_PRIOTOK] -'A';
- buf->time = LPRng_time(tokarr[LPRNG_TIMETOK]);
+ buf->time = LPRng_time(tokarr[LPRNG_TIMETOK]);
- fstrcpy(buf->fs_user,tokarr[LPRNG_USERTOK]);
+ fstrcpy(buf->fs_user,tokarr[LPRNG_USERTOK]);
- /* The '@hostname' prevents windows from displaying the printing icon
- * for the current user on the taskbar. Plop in a null.
- */
+ /* The '@hostname' prevents windows from displaying the printing icon
+ * for the current user on the taskbar. Plop in a null.
+ */
- if ((ptr = strchr_m(buf->fs_user,'@')) != NULL) {
- *ptr = '\0';
- }
+ if ((ptr = strchr_m(buf->fs_user,'@')) != NULL) {
+ *ptr = '\0';
+ }
- fstrcpy(buf->fs_file,tokarr[LPRNG_FILETOK]);
+ fstrcpy(buf->fs_file,tokarr[LPRNG_FILETOK]);
- if ((LPRNG_FILETOK + 1) != LPRNG_TOTALTOK) {
- int i;
+ if ((LPRNG_FILETOK + 1) != LPRNG_TOTALTOK) {
+ int i;
- for (i = (LPRNG_FILETOK + 1); i < LPRNG_TOTALTOK; i++) {
- /* FIXME: Using fstrcat rather than other means is a bit
- * inefficient; this might be a problem for enormous queues with
- * many fields. */
- fstrcat(buf->fs_file, " ");
- fstrcat(buf->fs_file, tokarr[i]);
- }
- /* Ensure null termination. */
- fstrterminate(buf->fs_file);
- }
+ for (i = (LPRNG_FILETOK + 1); i < LPRNG_TOTALTOK; i++) {
+ /* FIXME: Using fstrcat rather than other means is a bit
+ * inefficient; this might be a problem for enormous queues with
+ * many fields. */
+ fstrcat(buf->fs_file, " ");
+ fstrcat(buf->fs_file, tokarr[i]);
+ }
+ /* Ensure null termination. */
+ fstrterminate(buf->fs_file);
+ }
- return(True);
+ return True;
}
-
-
/*******************************************************************
parse lpq on an aix system
@@ -309,92 +329,87 @@ lazer lazer RUNNING 537 6297doc.A kvintus@IE 0 10 2445 1 1
QUEUED 540 L.ps root@IEDVB 172 1 4
QUEUED 541 P.ps root@IEDVB 22 1 5
********************************************************************/
+
static BOOL parse_lpq_aix(char *line,print_queue_struct *buf,BOOL first)
{
- fstring tok[11];
- int count=0;
- const char *cline = line;
-
- /* handle the case of "(standard input)" as a filename */
- string_sub(line,"standard input","STDIN",0);
- all_string_sub(line,"(","\"",0);
- all_string_sub(line,")","\"",0);
-
- for (count=0;
- count<10 &&
- next_token(&cline,tok[count],NULL, sizeof(tok[count]));
- count++) ;
-
- /* we must get 6 tokens */
- if (count < 10)
- {
- if ((count == 7) && ((strcmp(tok[0],"QUEUED") == 0) || (strcmp(tok[0],"HELD") == 0)))
- {
- /* the 2nd and 5th columns must be integer */
- if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4])) return(False);
- buf->size = atoi(tok[4]) * 1024;
- /* if the fname contains a space then use STDIN */
- if (strchr_m(tok[2],' '))
- fstrcpy(tok[2],"STDIN");
-
- /* only take the last part of the filename */
- {
- fstring tmp;
- char *p = strrchr_m(tok[2],'/');
- if (p)
- {
- fstrcpy(tmp,p+1);
- fstrcpy(tok[2],tmp);
- }
- }
-
-
- buf->job = atoi(tok[1]);
- buf->status = strequal(tok[0],"HELD")?LPQ_PAUSED:LPQ_QUEUED;
- buf->priority = 0;
- buf->time = time(NULL);
- fstrcpy(buf->fs_user,tok[3]);
- fstrcpy(buf->fs_file,tok[2]);
- }
- else
- {
- DEBUG(6,("parse_lpq_aix count=%d\n", count));
- return(False);
- }
- }
- else
- {
- /* the 4th and 9th columns must be integer */
- if (!isdigit((int)*tok[3]) || !isdigit((int)*tok[8])) return(False);
- buf->size = atoi(tok[8]) * 1024;
- /* if the fname contains a space then use STDIN */
- if (strchr_m(tok[4],' '))
- fstrcpy(tok[4],"STDIN");
-
- /* only take the last part of the filename */
- {
- fstring tmp;
- char *p = strrchr_m(tok[4],'/');
- if (p)
- {
- fstrcpy(tmp,p+1);
- fstrcpy(tok[4],tmp);
- }
- }
-
-
- buf->job = atoi(tok[3]);
- buf->status = strequal(tok[2],"RUNNING")?LPQ_PRINTING:LPQ_QUEUED;
- buf->priority = 0;
- buf->time = time(NULL);
- fstrcpy(buf->fs_user,tok[5]);
- fstrcpy(buf->fs_file,tok[4]);
- }
-
-
- return(True);
-}
+ fstring tok[11];
+ int count=0;
+ const char *cline = line;
+
+ /* handle the case of "(standard input)" as a filename */
+ string_sub(line,"standard input","STDIN",0);
+ all_string_sub(line,"(","\"",0);
+ all_string_sub(line,")","\"",0);
+
+ for (count=0; count<10 && next_token(&cline,tok[count],NULL, sizeof(tok[count])); count++) {
+ ;
+ }
+ /* we must get 6 tokens */
+ if (count < 10) {
+ if ((count == 7) && ((strcmp(tok[0],"QUEUED") == 0) || (strcmp(tok[0],"HELD") == 0))) {
+ /* the 2nd and 5th columns must be integer */
+ if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4])) {
+ return False;
+ }
+ buf->size = atoi(tok[4]) * 1024;
+ /* if the fname contains a space then use STDIN */
+ if (strchr_m(tok[2],' ')) {
+ fstrcpy(tok[2],"STDIN");
+ }
+
+ /* only take the last part of the filename */
+ {
+ fstring tmp;
+ char *p = strrchr_m(tok[2],'/');
+ if (p) {
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[2],tmp);
+ }
+ }
+
+ buf->job = atoi(tok[1]);
+ buf->status = strequal(tok[0],"HELD")?LPQ_PAUSED:LPQ_QUEUED;
+ buf->priority = 0;
+ buf->time = time(NULL);
+ fstrcpy(buf->fs_user,tok[3]);
+ fstrcpy(buf->fs_file,tok[2]);
+ } else {
+ DEBUG(6,("parse_lpq_aix count=%d\n", count));
+ return False;
+ }
+ } else {
+ /* the 4th and 9th columns must be integer */
+ if (!isdigit((int)*tok[3]) || !isdigit((int)*tok[8])) {
+ return False;
+ }
+
+ buf->size = atoi(tok[8]) * 1024;
+ /* if the fname contains a space then use STDIN */
+ if (strchr_m(tok[4],' ')) {
+ fstrcpy(tok[4],"STDIN");
+ }
+
+ /* only take the last part of the filename */
+ {
+ fstring tmp;
+ char *p = strrchr_m(tok[4],'/');
+ if (p) {
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[4],tmp);
+ }
+ }
+
+ buf->job = atoi(tok[3]);
+ buf->status = strequal(tok[2],"RUNNING")?LPQ_PRINTING:LPQ_QUEUED;
+ buf->priority = 0;
+ buf->time = time(NULL);
+ fstrcpy(buf->fs_user,tok[5]);
+ fstrcpy(buf->fs_file,tok[4]);
+ }
+
+ return True;
+}
/****************************************************************************
parse a lpq line
@@ -406,105 +421,123 @@ ljplus-2153 user priority 0 Jan 19 08:14 on ljplus
ljplus-2154 user priority 0 Jan 19 08:14 from client
(standard input) 7551 bytes
****************************************************************************/
+
static BOOL parse_lpq_hpux(char *line, print_queue_struct *buf, BOOL first)
{
- /* must read two lines to process, therefore keep some values static */
- static BOOL header_line_ok=False, base_prio_reset=False;
- static fstring jobuser;
- static int jobid;
- static int jobprio;
- static time_t jobtime;
- static int jobstat=LPQ_QUEUED;
- /* to store minimum priority to print, lpstat command should be invoked
- with -p option first, to work */
- static int base_prio;
- int count;
- char htab = '\011';
- const char *cline = line;
- fstring tok[12];
-
- /* If a line begins with a horizontal TAB, it is a subline type */
+ /* must read two lines to process, therefore keep some values static */
+ static BOOL header_line_ok=False, base_prio_reset=False;
+ static fstring jobuser;
+ static int jobid;
+ static int jobprio;
+ static time_t jobtime;
+ static int jobstat=LPQ_QUEUED;
+ /* to store minimum priority to print, lpstat command should be invoked
+ with -p option first, to work */
+ static int base_prio;
+ int count;
+ char htab = '\011';
+ const char *cline = line;
+ fstring tok[12];
+
+ /* If a line begins with a horizontal TAB, it is a subline type */
- if (line[0] == htab) { /* subline */
- /* check if it contains the base priority */
- if (!strncmp(line,"\tfence priority : ",18)) {
- base_prio=atoi(&line[18]);
- DEBUG(4, ("fence priority set at %d\n", base_prio));
- }
- if (!header_line_ok) return (False); /* incorrect header line */
- /* handle the case of "(standard input)" as a filename */
- string_sub(line,"standard input","STDIN",0);
- all_string_sub(line,"(","\"",0);
- all_string_sub(line,")","\"",0);
+ if (line[0] == htab) { /* subline */
+ /* check if it contains the base priority */
+ if (!strncmp(line,"\tfence priority : ",18)) {
+ base_prio=atoi(&line[18]);
+ DEBUG(4, ("fence priority set at %d\n", base_prio));
+ }
+
+ if (!header_line_ok) {
+ return False; /* incorrect header line */
+ }
+
+ /* handle the case of "(standard input)" as a filename */
+ string_sub(line,"standard input","STDIN",0);
+ all_string_sub(line,"(","\"",0);
+ all_string_sub(line,")","\"",0);
- for (count=0; count<2 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
- /* we must get 2 tokens */
- if (count < 2) return(False);
+ for (count=0; count<2 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
+ ;
+ }
+ /* we must get 2 tokens */
+ if (count < 2) {
+ return False;
+ }
- /* the 2nd column must be integer */
- if (!isdigit((int)*tok[1])) return(False);
+ /* the 2nd column must be integer */
+ if (!isdigit((int)*tok[1])) {
+ return False;
+ }
- /* if the fname contains a space then use STDIN */
- if (strchr_m(tok[0],' '))
- fstrcpy(tok[0],"STDIN");
+ /* if the fname contains a space then use STDIN */
+ if (strchr_m(tok[0],' ')) {
+ fstrcpy(tok[0],"STDIN");
+ }
- buf->size = atoi(tok[1]);
- fstrcpy(buf->fs_file,tok[0]);
+ buf->size = atoi(tok[1]);
+ fstrcpy(buf->fs_file,tok[0]);
- /* fill things from header line */
- buf->time = jobtime;
- buf->job = jobid;
- buf->status = jobstat;
- buf->priority = jobprio;
- fstrcpy(buf->fs_user,jobuser);
+ /* fill things from header line */
+ buf->time = jobtime;
+ buf->job = jobid;
+ buf->status = jobstat;
+ buf->priority = jobprio;
+ fstrcpy(buf->fs_user,jobuser);
- return(True);
- }
- else { /* header line */
- header_line_ok=False; /* reset it */
- if (first) {
- if (!base_prio_reset) {
- base_prio=0; /* reset it */
- base_prio_reset=True;
- }
- }
- else if (base_prio) base_prio_reset=False;
+ return True;
+ } else { /* header line */
+ header_line_ok=False; /* reset it */
+ if (first) {
+ if (!base_prio_reset) {
+ base_prio=0; /* reset it */
+ base_prio_reset=True;
+ }
+ } else if (base_prio) {
+ base_prio_reset=False;
+ }
- /* handle the dash in the job id */
- string_sub(line,"-"," ",0);
+ /* handle the dash in the job id */
+ string_sub(line,"-"," ",0);
- for (count=0; count<12 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
+ for (count=0; count<12 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
+ ;
+ }
- /* we must get 8 tokens */
- if (count < 8) return(False);
+ /* we must get 8 tokens */
+ if (count < 8) {
+ return False;
+ }
- /* first token must be printer name (cannot check ?) */
- /* the 2nd, 5th & 7th column must be integer */
- if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4]) || !isdigit((int)*tok[6])) return(False);
- jobid = atoi(tok[1]);
- fstrcpy(jobuser,tok[2]);
- jobprio = atoi(tok[4]);
+ /* first token must be printer name (cannot check ?) */
+ /* the 2nd, 5th & 7th column must be integer */
+ if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[4]) || !isdigit((int)*tok[6])) {
+ return False;
+ }
+ jobid = atoi(tok[1]);
+ fstrcpy(jobuser,tok[2]);
+ jobprio = atoi(tok[4]);
- /* process time */
- jobtime=EntryTime(tok, 5, count, 8);
- if (jobprio < base_prio) {
- jobstat = LPQ_PAUSED;
- DEBUG (4, ("job %d is paused: prio %d < %d; jobstat=%d\n", jobid, jobprio, base_prio, jobstat));
- }
- else {
- jobstat = LPQ_QUEUED;
- if ((count >8) && (((strequal(tok[8],"on")) ||
- ((strequal(tok[8],"from")) &&
- ((count > 10)&&(strequal(tok[10],"on")))))))
- jobstat = LPQ_PRINTING;
- }
+ /* process time */
+ jobtime=EntryTime(tok, 5, count, 8);
+ if (jobprio < base_prio) {
+ jobstat = LPQ_PAUSED;
+ DEBUG (4, ("job %d is paused: prio %d < %d; jobstat=%d\n",
+ jobid, jobprio, base_prio, jobstat));
+ } else {
+ jobstat = LPQ_QUEUED;
+ if ((count >8) && (((strequal(tok[8],"on")) ||
+ ((strequal(tok[8],"from")) &&
+ ((count > 10)&&(strequal(tok[10],"on"))))))) {
+ jobstat = LPQ_PRINTING;
+ }
+ }
- header_line_ok=True; /* information is correct */
- return(False); /* need subline info to include into queuelist */
- }
+ header_line_ok=True; /* information is correct */
+ return False; /* need subline info to include into queuelist */
+ }
}
-
/****************************************************************************
parse a lpstat line
@@ -514,68 +547,77 @@ dcslw-896 tridge 4712 Dec 20 10:30:30 on dcslw
dcslw-897 tridge 4712 Dec 20 10:30:30 being held
****************************************************************************/
+
static BOOL parse_lpq_sysv(char *line,print_queue_struct *buf,BOOL first)
{
- fstring tok[9];
- int count=0;
- char *p;
- const char *cline = line;
-
- /*
- * Handle the dash in the job id, but make sure that we skip over
- * the printer name in case we have a dash in that.
- * Patch from Dom.Mitchell@palmerharvey.co.uk.
- */
-
- /*
- * Move to the first space.
- */
- for (p = line ; !isspace(*p) && *p; p++)
- ;
-
- /*
- * Back up until the last '-' character or
- * start of line.
- */
- for (; (p >= line) && (*p != '-'); p--)
- ;
-
- if((p >= line) && (*p == '-'))
- *p = ' ';
-
- for (count=0; count<9 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++)
- ;
-
- /* we must get 7 tokens */
- if (count < 7)
- return(False);
-
- /* the 2nd and 4th, 6th columns must be integer */
- if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[3]))
- return(False);
- if (!isdigit((int)*tok[5]))
- return(False);
-
- /* if the user contains a ! then trim the first part of it */
- if ((p=strchr_m(tok[2],'!'))) {
- fstring tmp;
- fstrcpy(tmp,p+1);
- fstrcpy(tok[2],tmp);
- }
-
- buf->job = atoi(tok[1]);
- buf->size = atoi(tok[3]);
- if (count > 7 && strequal(tok[7],"on"))
- buf->status = LPQ_PRINTING;
- else if (count > 8 && strequal(tok[7],"being") && strequal(tok[8],"held"))
- buf->status = LPQ_PAUSED;
- else
- buf->status = LPQ_QUEUED;
- buf->priority = 0;
- buf->time = EntryTime(tok, 4, count, 7);
- fstrcpy(buf->fs_user,tok[2]);
- fstrcpy(buf->fs_file,tok[2]);
- return(True);
+ fstring tok[9];
+ int count=0;
+ char *p;
+ const char *cline = line;
+
+ /*
+ * Handle the dash in the job id, but make sure that we skip over
+ * the printer name in case we have a dash in that.
+ * Patch from Dom.Mitchell@palmerharvey.co.uk.
+ */
+
+ /*
+ * Move to the first space.
+ */
+ for (p = line ; !isspace(*p) && *p; p++) {
+ ;
+ }
+
+ /*
+ * Back up until the last '-' character or
+ * start of line.
+ */
+ for (; (p >= line) && (*p != '-'); p--) {
+ ;
+ }
+
+ if((p >= line) && (*p == '-')) {
+ *p = ' ';
+ }
+
+ for (count=0; count<9 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
+ ;
+ }
+
+ /* we must get 7 tokens */
+ if (count < 7) {
+ return False;
+ }
+
+ /* the 2nd and 4th, 6th columns must be integer */
+ if (!isdigit((int)*tok[1]) || !isdigit((int)*tok[3])) {
+ return False;
+ }
+ if (!isdigit((int)*tok[5])) {
+ return False;
+ }
+
+ /* if the user contains a ! then trim the first part of it */
+ if ((p=strchr_m(tok[2],'!'))) {
+ fstring tmp;
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[2],tmp);
+ }
+
+ buf->job = atoi(tok[1]);
+ buf->size = atoi(tok[3]);
+ if (count > 7 && strequal(tok[7],"on")) {
+ buf->status = LPQ_PRINTING;
+ } else if (count > 8 && strequal(tok[7],"being") && strequal(tok[8],"held")) {
+ buf->status = LPQ_PAUSED;
+ } else {
+ buf->status = LPQ_QUEUED;
+ }
+ buf->priority = 0;
+ buf->time = EntryTime(tok, 4, count, 7);
+ fstrcpy(buf->fs_user,tok[2]);
+ fstrcpy(buf->fs_file,tok[2]);
+ return True;
}
/****************************************************************************
@@ -588,56 +630,59 @@ Printer: txt (ready)
0001: root [job #2 ] ready 2378 bytes /etc/install
0002: root [job #3 ] ready 1146 bytes -- standard input --
****************************************************************************/
+
static BOOL parse_lpq_qnx(char *line,print_queue_struct *buf,BOOL first)
{
- fstring tok[7];
- int count=0;
- const char *cline = line;
-
- DEBUG(4,("antes [%s]\n", line));
-
- /* handle the case of "-- standard input --" as a filename */
- string_sub(line,"standard input","STDIN",0);
- DEBUG(4,("despues [%s]\n", line));
- all_string_sub(line,"-- ","\"",0);
- all_string_sub(line," --","\"",0);
- DEBUG(4,("despues 1 [%s]\n", line));
-
- string_sub(line,"[job #","",0);
- string_sub(line,"]","",0);
- DEBUG(4,("despues 2 [%s]\n", line));
-
- for (count=0; count<7 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
-
- /* we must get 7 tokens */
- if (count < 7)
- return(False);
-
- /* the 3rd and 5th columns must be integer */
- if (!isdigit((int)*tok[2]) || !isdigit((int)*tok[4])) return(False);
-
- /* only take the last part of the filename */
- {
- fstring tmp;
- char *p = strrchr_m(tok[6],'/');
- if (p)
- {
- fstrcpy(tmp,p+1);
- fstrcpy(tok[6],tmp);
- }
- }
-
+ fstring tok[7];
+ int count=0;
+ const char *cline = line;
- buf->job = atoi(tok[2]);
- buf->size = atoi(tok[4]);
- buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
- buf->priority = 0;
- buf->time = time(NULL);
- fstrcpy(buf->fs_user,tok[1]);
- fstrcpy(buf->fs_file,tok[6]);
- return(True);
-}
+ DEBUG(4,("antes [%s]\n", line));
+
+ /* handle the case of "-- standard input --" as a filename */
+ string_sub(line,"standard input","STDIN",0);
+ DEBUG(4,("despues [%s]\n", line));
+ all_string_sub(line,"-- ","\"",0);
+ all_string_sub(line," --","\"",0);
+ DEBUG(4,("despues 1 [%s]\n", line));
+ string_sub(line,"[job #","",0);
+ string_sub(line,"]","",0);
+ DEBUG(4,("despues 2 [%s]\n", line));
+
+ for (count=0; count<7 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
+ ;
+ }
+
+ /* we must get 7 tokens */
+ if (count < 7) {
+ return False;
+ }
+
+ /* the 3rd and 5th columns must be integer */
+ if (!isdigit((int)*tok[2]) || !isdigit((int)*tok[4])) {
+ return False;
+ }
+
+ /* only take the last part of the filename */
+ {
+ fstring tmp;
+ char *p = strrchr_m(tok[6],'/');
+ if (p) {
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[6],tmp);
+ }
+ }
+
+ buf->job = atoi(tok[2]);
+ buf->size = atoi(tok[4]);
+ buf->status = strequal(tok[3],"active")?LPQ_PRINTING:LPQ_QUEUED;
+ buf->priority = 0;
+ buf->time = time(NULL);
+ fstrcpy(buf->fs_user,tok[1]);
+ fstrcpy(buf->fs_file,tok[6]);
+ return True;
+}
/****************************************************************************
parse a lpq line for the plp printing system
@@ -652,61 +697,68 @@ Local Printer 'lp2' (fjall):
3rd tridge X - 7 fjall /etc/hosts 739 Jun 15 13:33
****************************************************************************/
+
static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
{
- fstring tok[11];
- int count=0;
- const char *cline = line;
-
- /* handle the case of "(standard input)" as a filename */
- string_sub(line,"stdin","STDIN",0);
- all_string_sub(line,"(","\"",0);
- all_string_sub(line,")","\"",0);
+ fstring tok[11];
+ int count=0;
+ const char *cline = line;
+
+ /* handle the case of "(standard input)" as a filename */
+ string_sub(line,"stdin","STDIN",0);
+ all_string_sub(line,"(","\"",0);
+ all_string_sub(line,")","\"",0);
- for (count=0; count<11 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) ;
-
- /* we must get 11 tokens */
- if (count < 11)
- return(False);
-
- /* the first must be "active" or begin with an integer */
- if (strcmp(tok[0],"active") && !isdigit((int)tok[0][0]))
- return(False);
-
- /* the 5th and 8th must be integer */
- if (!isdigit((int)*tok[4]) || !isdigit((int)*tok[7]))
- return(False);
-
- /* if the fname contains a space then use STDIN */
- if (strchr_m(tok[6],' '))
- fstrcpy(tok[6],"STDIN");
-
- /* only take the last part of the filename */
- {
- fstring tmp;
- char *p = strrchr_m(tok[6],'/');
- if (p)
- {
- fstrcpy(tmp,p+1);
- fstrcpy(tok[6],tmp);
- }
- }
-
-
- buf->job = atoi(tok[4]);
-
- buf->size = atoi(tok[7]);
- if (strchr_m(tok[7],'K'))
- buf->size *= 1024;
- if (strchr_m(tok[7],'M'))
- buf->size *= 1024*1024;
-
- buf->status = strequal(tok[0],"active")?LPQ_PRINTING:LPQ_QUEUED;
- buf->priority = 0;
- buf->time = time(NULL);
- fstrcpy(buf->fs_user,tok[1]);
- fstrcpy(buf->fs_file,tok[6]);
- return(True);
+ for (count=0; count<11 && next_token(&cline,tok[count],NULL,sizeof(tok[count])); count++) {
+ ;
+ }
+
+ /* we must get 11 tokens */
+ if (count < 11) {
+ return False;
+ }
+
+ /* the first must be "active" or begin with an integer */
+ if (strcmp(tok[0],"active") && !isdigit((int)tok[0][0])) {
+ return False;
+ }
+
+ /* the 5th and 8th must be integer */
+ if (!isdigit((int)*tok[4]) || !isdigit((int)*tok[7])) {
+ return False;
+ }
+
+ /* if the fname contains a space then use STDIN */
+ if (strchr_m(tok[6],' ')) {
+ fstrcpy(tok[6],"STDIN");
+ }
+
+ /* only take the last part of the filename */
+ {
+ fstring tmp;
+ char *p = strrchr_m(tok[6],'/');
+ if (p) {
+ fstrcpy(tmp,p+1);
+ fstrcpy(tok[6],tmp);
+ }
+ }
+
+ buf->job = atoi(tok[4]);
+
+ buf->size = atoi(tok[7]);
+ if (strchr_m(tok[7],'K')) {
+ buf->size *= 1024;
+ }
+ if (strchr_m(tok[7],'M')) {
+ buf->size *= 1024*1024;
+ }
+
+ buf->status = strequal(tok[0],"active")?LPQ_PRINTING:LPQ_QUEUED;
+ buf->priority = 0;
+ buf->time = time(NULL);
+ fstrcpy(buf->fs_user,tok[1]);
+ fstrcpy(buf->fs_file,tok[6]);
+ return True;
}
/*******************************************************************
@@ -722,6 +774,7 @@ root (9.99. Paused /usr/lib/rhs/rhs-pr 4 625 0 1
jmcd Waiting Re: Samba Open Sour 26 32476 1 1
********************************************************************/
+
static BOOL parse_lpq_nt(char *line,print_queue_struct *buf,BOOL first)
{
#define LPRNT_OWNSIZ 11
@@ -729,66 +782,70 @@ static BOOL parse_lpq_nt(char *line,print_queue_struct *buf,BOOL first)
#define LPRNT_JOBSIZ 19
#define LPRNT_IDSIZ 6
#define LPRNT_SIZSIZ 9
- typedef struct
- {
- char owner[LPRNT_OWNSIZ];
- char space1;
- char status[LPRNT_STATSIZ];
- char space2;
- char jobname[LPRNT_JOBSIZ];
- char space3;
- char jobid[LPRNT_IDSIZ];
- char space4;
- char size[LPRNT_SIZSIZ];
- char terminator;
- } nt_lpq_line;
-
- nt_lpq_line parse_line;
+ typedef struct {
+ char owner[LPRNT_OWNSIZ];
+ char space1;
+ char status[LPRNT_STATSIZ];
+ char space2;
+ char jobname[LPRNT_JOBSIZ];
+ char space3;
+ char jobid[LPRNT_IDSIZ];
+ char space4;
+ char size[LPRNT_SIZSIZ];
+ char terminator;
+ } nt_lpq_line;
+
+ nt_lpq_line parse_line;
#define LPRNT_PRINTING "Printing"
#define LPRNT_WAITING "Waiting"
#define LPRNT_PAUSED "Paused"
- memset(&parse_line, '\0', sizeof(parse_line));
- strncpy((char *) &parse_line, line, sizeof(parse_line) -1);
-
- if (strlen((char *) &parse_line) != sizeof(parse_line) - 1)
- return(False);
-
- /* Just want the first word in the owner field - the username */
- if (strchr_m(parse_line.owner, ' '))
- *(strchr_m(parse_line.owner, ' ')) = '\0';
- else
- parse_line.space1 = '\0';
-
- /* Make sure we have an owner */
- if (!strlen(parse_line.owner))
- return(False);
-
- /* Make sure the status is valid */
- parse_line.space2 = '\0';
- trim_char(parse_line.status, '\0', ' ');
- if (!strequal(parse_line.status, LPRNT_PRINTING) &&
- !strequal(parse_line.status, LPRNT_PAUSED) &&
- !strequal(parse_line.status, LPRNT_WAITING))
- return(False);
+ memset(&parse_line, '\0', sizeof(parse_line));
+ strncpy((char *) &parse_line, line, sizeof(parse_line) -1);
+
+ if (strlen((char *) &parse_line) != sizeof(parse_line) - 1) {
+ return False;
+ }
+
+ /* Just want the first word in the owner field - the username */
+ if (strchr_m(parse_line.owner, ' ')) {
+ *(strchr_m(parse_line.owner, ' ')) = '\0';
+ } else {
+ parse_line.space1 = '\0';
+ }
+
+ /* Make sure we have an owner */
+ if (!strlen(parse_line.owner)) {
+ return False;
+ }
+
+ /* Make sure the status is valid */
+ parse_line.space2 = '\0';
+ trim_char(parse_line.status, '\0', ' ');
+ if (!strequal(parse_line.status, LPRNT_PRINTING) &&
+ !strequal(parse_line.status, LPRNT_PAUSED) &&
+ !strequal(parse_line.status, LPRNT_WAITING)) {
+ return False;
+ }
- parse_line.space3 = '\0';
- trim_char(parse_line.jobname, '\0', ' ');
-
- buf->job = atoi(parse_line.jobid);
- buf->priority = 0;
- buf->size = atoi(parse_line.size);
- buf->time = time(NULL);
- fstrcpy(buf->fs_user, parse_line.owner);
- fstrcpy(buf->fs_file, parse_line.jobname);
- if (strequal(parse_line.status, LPRNT_PRINTING))
- buf->status = LPQ_PRINTING;
- else if (strequal(parse_line.status, LPRNT_PAUSED))
- buf->status = LPQ_PAUSED;
- else
- buf->status = LPQ_QUEUED;
-
- return(True);
+ parse_line.space3 = '\0';
+ trim_char(parse_line.jobname, '\0', ' ');
+
+ buf->job = atoi(parse_line.jobid);
+ buf->priority = 0;
+ buf->size = atoi(parse_line.size);
+ buf->time = time(NULL);
+ fstrcpy(buf->fs_user, parse_line.owner);
+ fstrcpy(buf->fs_file, parse_line.jobname);
+ if (strequal(parse_line.status, LPRNT_PRINTING)) {
+ buf->status = LPQ_PRINTING;
+ } else if (strequal(parse_line.status, LPRNT_PAUSED)) {
+ buf->status = LPQ_PAUSED;
+ } else {
+ buf->status = LPQ_QUEUED;
+ }
+
+ return True;
}
/*******************************************************************
@@ -800,6 +857,7 @@ JobID File Name Rank Size Status Comment
4 /etc/motd 2 11666 Queued root@psflinu
********************************************************************/
+
static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
{
#define LPROS2_IDSIZ 5
@@ -807,64 +865,67 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first)
#define LPROS2_SIZSIZ 8
#define LPROS2_STATSIZ 12
#define LPROS2_OWNSIZ 12
- typedef struct
- {
- char jobid[LPROS2_IDSIZ];
- char space1[2];
- char jobname[LPROS2_JOBSIZ];
- char space2[14];
- char size[LPROS2_SIZSIZ];
- char space3[4];
- char status[LPROS2_STATSIZ];
- char space4[4];
- char owner[LPROS2_OWNSIZ];
- char terminator;
- } os2_lpq_line;
-
- os2_lpq_line parse_line;
+ typedef struct {
+ char jobid[LPROS2_IDSIZ];
+ char space1[2];
+ char jobname[LPROS2_JOBSIZ];
+ char space2[14];
+ char size[LPROS2_SIZSIZ];
+ char space3[4];
+ char status[LPROS2_STATSIZ];
+ char space4[4];
+ char owner[LPROS2_OWNSIZ];
+ char terminator;
+ } os2_lpq_line;
+
+ os2_lpq_line parse_line;
#define LPROS2_PRINTING "Printing"
#define LPROS2_WAITING "Queued"
#define LPROS2_PAUSED "Paused"
- memset(&parse_line, '\0', sizeof(parse_line));
- strncpy((char *) &parse_line, line, sizeof(parse_line) -1);
-
- if (strlen((char *) &parse_line) != sizeof(parse_line) - 1)
- return(False);
-
- /* Get the jobid */
- buf->job = atoi(parse_line.jobid);
-
- /* Get the job name */
- parse_line.space2[0] = '\0';
- trim_char(parse_line.jobname, '\0', ' ');
- fstrcpy(buf->fs_file, parse_line.jobname);
-
- buf->priority = 0;
- buf->size = atoi(parse_line.size);
- buf->time = time(NULL);
-
- /* Make sure we have an owner */
- if (!strlen(parse_line.owner))
- return(False);
-
- /* Make sure we have a valid status */
- parse_line.space4[0] = '\0';
- trim_char(parse_line.status, '\0', ' ');
- if (!strequal(parse_line.status, LPROS2_PRINTING) &&
- !strequal(parse_line.status, LPROS2_PAUSED) &&
- !strequal(parse_line.status, LPROS2_WAITING))
- return(False);
-
- fstrcpy(buf->fs_user, parse_line.owner);
- if (strequal(parse_line.status, LPROS2_PRINTING))
- buf->status = LPQ_PRINTING;
- else if (strequal(parse_line.status, LPROS2_PAUSED))
- buf->status = LPQ_PAUSED;
- else
- buf->status = LPQ_QUEUED;
-
- return(True);
+ memset(&parse_line, '\0', sizeof(parse_line));
+ strncpy((char *) &parse_line, line, sizeof(parse_line) -1);
+
+ if (strlen((char *) &parse_line) != sizeof(parse_line) - 1) {
+ return False;
+ }
+
+ /* Get the jobid */
+ buf->job = atoi(parse_line.jobid);
+
+ /* Get the job name */
+ parse_line.space2[0] = '\0';
+ trim_char(parse_line.jobname, '\0', ' ');
+ fstrcpy(buf->fs_file, parse_line.jobname);
+
+ buf->priority = 0;
+ buf->size = atoi(parse_line.size);
+ buf->time = time(NULL);
+
+ /* Make sure we have an owner */
+ if (!strlen(parse_line.owner)) {
+ return False;
+ }
+
+ /* Make sure we have a valid status */
+ parse_line.space4[0] = '\0';
+ trim_char(parse_line.status, '\0', ' ');
+ if (!strequal(parse_line.status, LPROS2_PRINTING) &&
+ !strequal(parse_line.status, LPROS2_PAUSED) &&
+ !strequal(parse_line.status, LPROS2_WAITING)) {
+ return False;
+ }
+
+ fstrcpy(buf->fs_user, parse_line.owner);
+ if (strequal(parse_line.status, LPROS2_PRINTING)) {
+ buf->status = LPQ_PRINTING;
+ } else if (strequal(parse_line.status, LPROS2_PAUSED)) {
+ buf->status = LPQ_PAUSED;
+ } else {
+ buf->status = LPQ_QUEUED;
+ }
+
+ return True;
}
static const char *stat0_strings[] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL };
@@ -876,6 +937,7 @@ static const char *stat2_strings[] = { "jam", "paper", "error", "responding", "n
/****************************************************************************
parse a vlp line
****************************************************************************/
+
static BOOL parse_lpq_vlp(char *line,print_queue_struct *buf,BOOL first)
{
int toknum = 0;
@@ -925,92 +987,96 @@ BOOL parse_lpq_entry(enum printing_types printing_type,char *line,
print_queue_struct *buf,
print_status_struct *status,BOOL first)
{
- BOOL ret;
-
- switch (printing_type)
- {
- case PRINT_SYSV:
- ret = parse_lpq_sysv(line,buf,first);
- break;
- case PRINT_AIX:
- ret = parse_lpq_aix(line,buf,first);
- break;
- case PRINT_HPUX:
- ret = parse_lpq_hpux(line,buf,first);
- break;
- case PRINT_QNX:
- ret = parse_lpq_qnx(line,buf,first);
- break;
- case PRINT_LPRNG:
- ret = parse_lpq_lprng(line,buf,first);
- break;
- case PRINT_PLP:
- ret = parse_lpq_plp(line,buf,first);
- break;
- case PRINT_LPRNT:
- ret = parse_lpq_nt(line,buf,first);
- break;
- case PRINT_LPROS2:
- ret = parse_lpq_os2(line,buf,first);
- break;
+ BOOL ret;
+
+ switch (printing_type) {
+ case PRINT_SYSV:
+ ret = parse_lpq_sysv(line,buf,first);
+ break;
+ case PRINT_AIX:
+ ret = parse_lpq_aix(line,buf,first);
+ break;
+ case PRINT_HPUX:
+ ret = parse_lpq_hpux(line,buf,first);
+ break;
+ case PRINT_QNX:
+ ret = parse_lpq_qnx(line,buf,first);
+ break;
+ case PRINT_LPRNG:
+ ret = parse_lpq_lprng(line,buf,first);
+ break;
+ case PRINT_PLP:
+ ret = parse_lpq_plp(line,buf,first);
+ break;
+ case PRINT_LPRNT:
+ ret = parse_lpq_nt(line,buf,first);
+ break;
+ case PRINT_LPROS2:
+ ret = parse_lpq_os2(line,buf,first);
+ break;
#ifdef DEVELOPER
- case PRINT_VLP:
- case PRINT_TEST:
- ret = parse_lpq_vlp(line,buf,first);
- break;
+ case PRINT_VLP:
+ case PRINT_TEST:
+ ret = parse_lpq_vlp(line,buf,first);
+ break;
#endif /* DEVELOPER */
- default:
- ret = parse_lpq_bsd(line,buf,first);
- break;
- }
-
- /* We don't want the newline in the status message. */
- {
- char *p = strchr_m(line,'\n');
- if (p) *p = 0;
- }
-
- /* in the LPRNG case, we skip lines starting by a space.*/
- if (!ret && (printing_type==PRINT_LPRNG) )
- {
- if (line[0]==' ')
- return ret;
- }
-
-
- if (status && !ret)
- {
- /* a few simple checks to see if the line might be a
- printer status line:
- handle them so that most severe condition is shown */
- int i;
- strlower_m(line);
+ default:
+ ret = parse_lpq_bsd(line,buf,first);
+ break;
+ }
+
+ /* We don't want the newline in the status message. */
+ {
+ char *p = strchr_m(line,'\n');
+ if (p) {
+ *p = 0;
+ }
+ }
+
+ /* in the LPRNG case, we skip lines starting by a space.*/
+ if (!ret && (printing_type==PRINT_LPRNG) ) {
+ if (line[0]==' ') {
+ return ret;
+ }
+ }
+
+ if (status && !ret) {
+ /* a few simple checks to see if the line might be a
+ printer status line:
+ handle them so that most severe condition is shown */
+ int i;
+ strlower_m(line);
- switch (status->status) {
- case LPSTAT_OK:
- for (i=0; stat0_strings[i]; i++)
- if (strstr_m(line,stat0_strings[i])) {
- fstrcpy(status->message,line);
- status->status=LPSTAT_OK;
- return ret;
- }
- case LPSTAT_STOPPED:
- for (i=0; stat1_strings[i]; i++)
- if (strstr_m(line,stat1_strings[i])) {
- fstrcpy(status->message,line);
- status->status=LPSTAT_STOPPED;
- return ret;
- }
- case LPSTAT_ERROR:
- for (i=0; stat2_strings[i]; i++)
- if (strstr_m(line,stat2_strings[i])) {
- fstrcpy(status->message,line);
- status->status=LPSTAT_ERROR;
- return ret;
- }
- break;
- }
- }
-
- return(ret);
+ switch (status->status) {
+ case LPSTAT_OK:
+ for (i=0; stat0_strings[i]; i++) {
+ if (strstr_m(line,stat0_strings[i])) {
+ fstrcpy(status->message,line);
+ status->status=LPSTAT_OK;
+ return ret;
+ }
+ }
+ /* fallthrough */
+ case LPSTAT_STOPPED:
+ for (i=0; stat1_strings[i]; i++) {
+ if (strstr_m(line,stat1_strings[i])) {
+ fstrcpy(status->message,line);
+ status->status=LPSTAT_STOPPED;
+ return ret;
+ }
+ }
+ /* fallthrough */
+ case LPSTAT_ERROR:
+ for (i=0; stat2_strings[i]; i++) {
+ if (strstr_m(line,stat2_strings[i])) {
+ fstrcpy(status->message,line);
+ status->status=LPSTAT_ERROR;
+ return ret;
+ }
+ }
+ break;
+ }
+ }
+
+ return ret;
}
diff --git a/source/printing/printing.c b/source/printing/printing.c
index b131727f8a4..c7ca917af0e 100644
--- a/source/printing/printing.c
+++ b/source/printing/printing.c
@@ -337,27 +337,38 @@ static struct printjob *print_job_find(const char *sharename, uint32 jobid)
TDB_DATA ret;
struct tdb_print_db *pdb = get_print_db_byname(sharename);
+ DEBUG(10,("print_job_find: looking up job %u for share %s\n",
+ (unsigned int)jobid, sharename ));
- if (!pdb)
+ if (!pdb) {
return NULL;
+ }
ret = tdb_fetch(pdb->tdb, print_key(jobid));
release_print_db(pdb);
- if (!ret.dptr)
+ if (!ret.dptr) {
+ DEBUG(10,("print_job_find: failed to find jobid %u.\n", (unsigned int)jobid ));
return NULL;
+ }
- if ( pjob.nt_devmode )
+ if ( pjob.nt_devmode ) {
free_nt_devicemode( &pjob.nt_devmode );
+ }
ZERO_STRUCT( pjob );
if ( unpack_pjob( ret.dptr, ret.dsize, &pjob ) == -1 ) {
+ DEBUG(10,("print_job_find: failed to unpack jobid %u.\n", (unsigned int)jobid ));
SAFE_FREE(ret.dptr);
return NULL;
}
- SAFE_FREE(ret.dptr);
+ SAFE_FREE(ret.dptr);
+
+ DEBUG(10,("print_job_find: returning system job %d for jobid %u.\n",
+ (int)pjob.sysjob, (unsigned int)jobid ));
+
return &pjob;
}
@@ -2014,11 +2025,17 @@ BOOL print_job_pause(struct current_user *user, int snum, uint32 jobid, WERROR *
pjob = print_job_find(sharename, jobid);
- if (!pjob || !user)
+ if (!pjob || !user) {
+ DEBUG(10, ("print_job_pause: no pjob or user for jobid %u\n",
+ (unsigned int)jobid ));
return False;
+ }
- if (!pjob->spooled || pjob->sysjob == -1)
+ if (!pjob->spooled || pjob->sysjob == -1) {
+ DEBUG(10, ("print_job_pause: not spooled or bad sysjob = %d for jobid %u\n",
+ (int)pjob->sysjob, (unsigned int)jobid ));
return False;
+ }
if (!is_owner(user, snum, jobid) &&
!print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
@@ -2068,11 +2085,17 @@ BOOL print_job_resume(struct current_user *user, int snum, uint32 jobid, WERROR
pjob = print_job_find(sharename, jobid);
- if (!pjob || !user)
+ if (!pjob || !user) {
+ DEBUG(10, ("print_job_resume: no pjob or user for jobid %u\n",
+ (unsigned int)jobid ));
return False;
+ }
- if (!pjob->spooled || pjob->sysjob == -1)
+ if (!pjob->spooled || pjob->sysjob == -1) {
+ DEBUG(10, ("print_job_resume: not spooled or bad sysjob = %d for jobid %u\n",
+ (int)pjob->sysjob, (unsigned int)jobid ));
return False;
+ }
if (!is_owner(user, snum, jobid) &&
!print_access_check(user, snum, JOB_ACCESS_ADMINISTER)) {
diff --git a/source/rpc_server/srv_netlog_nt.c b/source/rpc_server/srv_netlog_nt.c
index d512115e832..10cd5c82bae 100644
--- a/source/rpc_server/srv_netlog_nt.c
+++ b/source/rpc_server/srv_netlog_nt.c
@@ -238,7 +238,7 @@ static NTSTATUS get_md4pw(char *md4pw, char *mach_acct, uint16 sec_chan_type)
ret = pdb_getsampwnam(sampass, mach_acct);
unbecome_root();
- if (ret == False) {
+ if (!ret) {
DEBUG(0,("get_md4pw: Workstation %s: no account in domain\n", mach_acct));
TALLOC_FREE(sampass);
return NT_STATUS_ACCESS_DENIED;
@@ -562,26 +562,30 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *
}
/* We must store the creds state after an update. */
+ sampass = samu_new( NULL );
+ if (!sampass) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
become_root();
secrets_store_schannel_session_info(p->pipe_state_mem_ctx,
remote_machine,
p->dc);
- if ( (sampass = samu_new( NULL )) != NULL ) {
- ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
- }
+ ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
unbecome_root();
- if ( !sampass )
- return NT_STATUS_NO_MEMORY;
+ if (!ret) {
+ TALLOC_FREE(sampass);
+ return NT_STATUS_ACCESS_DENIED;
+ }
/* Ensure the account exists and is a machine account. */
acct_ctrl = pdb_get_acct_ctrl(sampass);
- if (!(ret
- && (acct_ctrl & ACB_WSTRUST ||
+ if (!(acct_ctrl & ACB_WSTRUST ||
acct_ctrl & ACB_SVRTRUST ||
- acct_ctrl & ACB_DOMTRUST))) {
+ acct_ctrl & ACB_DOMTRUST)) {
TALLOC_FREE(sampass);
return NT_STATUS_NO_SUCH_USER;
}
@@ -626,7 +630,7 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *
}
become_root();
- r_u->status = pdb_update_sam_account (sampass);
+ r_u->status = pdb_update_sam_account(sampass);
unbecome_root();
}
diff --git a/source/smbd/chgpasswd.c b/source/smbd/chgpasswd.c
index 011122ee575..cd847240ddb 100644
--- a/source/smbd/chgpasswd.c
+++ b/source/smbd/chgpasswd.c
@@ -579,6 +579,11 @@ BOOL check_lanman_password(char *user, uchar * pass1,
uint32 acct_ctrl;
const uint8 *lanman_pw;
BOOL ret;
+
+ if ( !(sampass = samu_new(NULL)) ) {
+ DEBUG(0, ("samu_new() failed!\n"));
+ return False;
+ }
become_root();
ret = pdb_getsampwnam(sampass, user);
diff --git a/source/smbd/lanman.c b/source/smbd/lanman.c
index 4d4d9d22591..e4531d8ae98 100644
--- a/source/smbd/lanman.c
+++ b/source/smbd/lanman.c
@@ -2010,6 +2010,12 @@ static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *para
return False;
}
+ if ( !(sampw = samu_new(mem_ctx)) ) {
+ DEBUG(0, ("samu_new() failed!\n"));
+ TALLOC_FREE(mem_ctx);
+ return False;
+ }
+
/* Lookup the user information; This should only be one of
our accounts (not remote domains) */
@@ -2027,11 +2033,6 @@ static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *para
goto done;
}
- if ( !(sampw = samu_new(mem_ctx)) ) {
- DEBUG(0, ("samu_new() failed!\n"));
- goto done;
- }
-
if ( !pdb_getsampwsid(sampw, &user_sid) ) {
DEBUG(10, ("pdb_getsampwsid(%s) failed for user %s\n",
sid_string_static(&user_sid), UserName));
@@ -2212,6 +2213,9 @@ static BOOL api_NetRemoteTOD(connection_struct *conn,uint16 vuid, char *param,ch
/* the client expects to get localtime, not GMT, in this bit
(I think, this needs testing) */
t = localtime(&unixdate);
+ if (!t) {
+ return False;
+ }
SIVAL(p,4,0); /* msecs ? */
SCVAL(p,8,t->tm_hour);
diff --git a/source/smbd/msdfs.c b/source/smbd/msdfs.c
index 700aa2ae81c..55a6850478f 100644
--- a/source/smbd/msdfs.c
+++ b/source/smbd/msdfs.c
@@ -203,7 +203,8 @@ static BOOL parse_symlink(TALLOC_CTX *ctx, char *buf, struct referral **preflist
}
/* parse out the alternate paths */
- while(((alt_path[count] = strtok(NULL,",")) != NULL) && count<MAX_REFERRAL_COUNT) {
+ while((count<MAX_REFERRAL_COUNT) &&
+ ((alt_path[count] = strtok(NULL,",")) != NULL)) {
count++;
}
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 633e70ac314..2e4091d937e 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -1107,7 +1107,6 @@ files_struct *open_file_ntcreate(connection_struct *conn,
uint32 existing_dos_attributes = 0;
struct pending_message_list *pml = NULL;
uint16 mid = get_current_mid();
- BOOL delayed_for_oplocks = False;
struct timeval request_time = timeval_zero();
struct share_mode_lock *lck = NULL;
NTSTATUS status;
@@ -1148,7 +1147,6 @@ files_struct *open_file_ntcreate(connection_struct *conn,
see if this has timed out. */
request_time = pml->request_time;
- delayed_for_oplocks = state->delayed_for_oplocks;
/* Remove the deferred open entry under lock. */
lck = get_share_mode_lock(NULL, state->dev, state->inode, NULL, NULL);
@@ -1905,7 +1903,6 @@ files_struct *open_directory(connection_struct *conn,
DEBUG(5,("open_directory: invalid create_disposition "
"0x%x for directory %s\n",
(unsigned int)create_disposition, fname));
- file_free(fsp);
set_saved_ntstatus(NT_STATUS_INVALID_PARAMETER);
return NULL;
}
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index 71ff79081de..86743f626e6 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -2813,7 +2813,6 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
char *fullpathname;
char *base_name;
char *p;
- char *lock_data = NULL;
SMB_OFF_T pos = 0;
BOOL bad_path = False;
BOOL delete_pending = False;
@@ -2823,6 +2822,9 @@ static int call_trans2qfilepathinfo(connection_struct *conn, char *inbuf, char *
TALLOC_CTX *data_ctx = NULL;
struct ea_list *ea_list = NULL;
uint32 access_mask = 0x12019F; /* Default - GENERIC_EXECUTE mapping from Windows */
+#if defined(DEVELOPER)
+ char *lock_data = NULL;
+#endif
if (!params)
return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
diff --git a/source/utils/net_cache.c b/source/utils/net_cache.c
index 0c107a5f01d..69b3327f7a9 100644
--- a/source/utils/net_cache.c
+++ b/source/utils/net_cache.c
@@ -37,24 +37,36 @@
static void print_cache_entry(const char* keystr, const char* datastr,
const time_t timeout, void* dptr)
{
- char* timeout_str;
+ char *timeout_str;
time_t now_t = time(NULL);
struct tm timeout_tm, *now_tm;
/* localtime returns statically allocated pointer, so timeout_tm
has to be copied somewhere else */
- memcpy(&timeout_tm, localtime(&timeout), sizeof(struct tm));
+
+ now_tm = localtime(&timeout);
+ if (!now_tm) {
+ return;
+ }
+ memcpy(&timeout_tm, now_tm, sizeof(struct tm));
now_tm = localtime(&now_t);
+ if (!now_tm) {
+ return;
+ }
/* form up timeout string depending whether it's today's date or not */
if (timeout_tm.tm_year != now_tm->tm_year ||
- timeout_tm.tm_mon != now_tm->tm_mon ||
- timeout_tm.tm_mday != now_tm->tm_mday) {
+ timeout_tm.tm_mon != now_tm->tm_mon ||
+ timeout_tm.tm_mday != now_tm->tm_mday) {
- timeout_str = asctime(&timeout_tm);
- timeout_str[strlen(timeout_str) - 1] = '\0'; /* remove tailing CR */
- } else
+ timeout_str = asctime(&timeout_tm);
+ if (!timeout_str) {
+ return;
+ }
+ timeout_str[strlen(timeout_str) - 1] = '\0'; /* remove tailing CR */
+ } else {
asprintf(&timeout_str, "%.2d:%.2d:%.2d", timeout_tm.tm_hour,
timeout_tm.tm_min, timeout_tm.tm_sec);
+ }
d_printf("Key: %s\t Timeout: %s\t Value: %s %s\n", keystr,
timeout_str, datastr, timeout > now_t ? "": "(expired)");
diff --git a/source/utils/net_status.c b/source/utils/net_status.c
index d85bd27b16d..c68c9f6e2fb 100644
--- a/source/utils/net_status.c
+++ b/source/utils/net_status.c
@@ -104,7 +104,7 @@ static int show_share(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
d_printf("%-10.10s %s %-12s %s",
crec.name,procid_str_static(&crec.pid),
crec.machine,
- asctime(localtime(&crec.start)));
+ time_to_asc(&crec.start));
return 0;
}
@@ -173,7 +173,7 @@ static int show_share_parseable(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
guest ? "" : gidtoname(ids->entries[i].gid),
crec.machine,
guest ? "" : ids->entries[i].hostname,
- asctime(localtime(&crec.start)));
+ time_to_asc(&crec.start));
return 0;
}
diff --git a/source/utils/net_time.c b/source/utils/net_time.c
index 1a7116d447d..f6486286a65 100644
--- a/source/utils/net_time.c
+++ b/source/utils/net_time.c
@@ -69,12 +69,15 @@ static time_t nettime(int *zone)
}
/* return a time as a string ready to be passed to /bin/date */
-static char *systime(time_t t)
+static const char *systime(time_t t)
{
static fstring s;
struct tm *tm;
tm = localtime(&t);
+ if (!tm) {
+ return "unknown";
+ }
fstr_sprintf(s, "%02d%02d%02d%02d%04d.%02d",
tm->tm_mon+1, tm->tm_mday, tm->tm_hour,
diff --git a/source/utils/net_usershare.c b/source/utils/net_usershare.c
index 1ee156c4ee0..ca9ca4e6e21 100644
--- a/source/utils/net_usershare.c
+++ b/source/utils/net_usershare.c
@@ -129,7 +129,7 @@ int net_usershare_usage(int argc, const char **argv)
static void get_basepath(pstring basepath)
{
pstrcpy(basepath, lp_usershare_path());
- if (basepath[strlen(basepath)-1] == '/') {
+ if ((basepath[0] != '\0') && (basepath[strlen(basepath)-1] == '/')) {
basepath[strlen(basepath)-1] = '\0';
}
}
diff --git a/source/utils/ntlm_auth_diagnostics.c b/source/utils/ntlm_auth_diagnostics.c
index 95f1355c2eb..00149db9e24 100644
--- a/source/utils/ntlm_auth_diagnostics.c
+++ b/source/utils/ntlm_auth_diagnostics.c
@@ -470,7 +470,7 @@ static BOOL test_plaintext(enum ntlm_break break_which)
CH_DOS, password,
strlen(password)+1,
(void**)&lm_response.data,True)) == -1) {
- DEBUG(0, ("push_ascii_allocate failed!\n"));
+ DEBUG(0, ("convert_string_allocate failed!\n"));
exit(1);
}
diff --git a/source/utils/smbpasswd.c b/source/utils/smbpasswd.c
index 24b3759605b..da9ac8d279d 100644
--- a/source/utils/smbpasswd.c
+++ b/source/utils/smbpasswd.c
@@ -403,12 +403,19 @@ static int process_root(int local_flags)
if(local_flags & LOCAL_ENABLE_USER) {
struct samu *sampass = NULL;
- BOOL ret;
sampass = samu_new( NULL );
- ret = pdb_getsampwnam(sampass, user_name);
- if((ret) &&
- (pdb_get_nt_passwd(sampass) == NULL)) {
+ if (!sampass) {
+ fprintf(stderr, "talloc fail for struct samu.\n");
+ exit(1);
+ }
+ if (!pdb_getsampwnam(sampass, user_name)) {
+ fprintf(stderr, "Failed to find user %s in passdb backend.\n",
+ user_name );
+ exit(1);
+ }
+
+ if(pdb_get_nt_passwd(sampass) == NULL) {
local_flags |= LOCAL_SET_PASSWORD;
}
TALLOC_FREE(sampass);
@@ -437,16 +444,26 @@ static int process_root(int local_flags)
printf("Password changed for user %s on %s.\n", user_name, remote_machine );
} else if(!(local_flags & (LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_ENABLE_USER|LOCAL_DELETE_USER|LOCAL_SET_NO_PASSWORD|LOCAL_SET_PASSWORD))) {
struct samu *sampass = NULL;
- BOOL ret;
sampass = samu_new( NULL );
- ret = pdb_getsampwnam(sampass, user_name);
+ if (!sampass) {
+ fprintf(stderr, "talloc fail for struct samu.\n");
+ exit(1);
+ }
+
+ if (!pdb_getsampwnam(sampass, user_name)) {
+ fprintf(stderr, "Failed to find user %s in passdb backend.\n",
+ user_name );
+ exit(1);
+ }
printf("Password changed for user %s.", user_name );
- if( (ret != False) && (pdb_get_acct_ctrl(sampass)&ACB_DISABLED) )
+ if(pdb_get_acct_ctrl(sampass)&ACB_DISABLED) {
printf(" User has disabled flag set.");
- if((ret != False) && (pdb_get_acct_ctrl(sampass) & ACB_PWNOTREQ) )
+ }
+ if(pdb_get_acct_ctrl(sampass) & ACB_PWNOTREQ) {
printf(" User has no password flag set.");
+ }
printf("\n");
TALLOC_FREE(sampass);
}
diff --git a/source/utils/status.c b/source/utils/status.c
index 05075da444f..2566c8a50de 100644
--- a/source/utils/status.c
+++ b/source/utils/status.c
@@ -155,7 +155,7 @@ static void print_share_mode(const struct share_mode_entry *e, const char *share
d_printf("NONE ");
}
- d_printf(" %s %s %s",sharepath, fname, asctime(localtime((time_t *)&e->time.tv_sec)));
+ d_printf(" %s %s %s",sharepath, fname, time_to_asc((time_t *)&e->time.tv_sec));
}
}
@@ -562,7 +562,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *st
d_printf("%-10s %s %-12s %s",
crec.name,procid_str_static(&crec.pid),
crec.machine,
- asctime(localtime(&crec.start)));
+ time_to_asc(&crec.start));
return 0;
}
diff --git a/source/web/statuspage.c b/source/web/statuspage.c
index 7430f4ebf59..769ab217b3e 100644
--- a/source/web/statuspage.c
+++ b/source/web/statuspage.c
@@ -101,7 +101,7 @@ static char *mapPid2Machine (struct process_id pid)
static char *tstring(time_t t)
{
static pstring buf;
- pstrcpy(buf, asctime(localtime(&t)));
+ pstrcpy(buf, time_to_asc(&t));
all_string_sub(buf," ","&nbsp;",sizeof(buf));
return buf;
}