summaryrefslogtreecommitdiff
path: root/source3/smbd/utmp.c
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2012-08-23 15:21:06 +0200
committerMichael Adam <obnox@samba.org>2012-10-19 12:15:00 +0200
commitb288ddd5c0ee7524e30a4fce3ec4f03c19a1764a (patch)
tree5274a6e05da5639ef76913a77592ba32f1fdd314 /source3/smbd/utmp.c
parent92d53dd7dc8ca71ae28d2a8762524396cd3c6f58 (diff)
downloadsamba-b288ddd5c0ee7524e30a4fce3ec4f03c19a1764a.tar.gz
samba-b288ddd5c0ee7524e30a4fce3ec4f03c19a1764a.tar.bz2
samba-b288ddd5c0ee7524e30a4fce3ec4f03c19a1764a.zip
s3:smbd: use session_global_id as session number for pam and utmp
Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/smbd/utmp.c')
-rw-r--r--source3/smbd/utmp.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c
index bb48d36946..0dc1917bfe 100644
--- a/source3/smbd/utmp.c
+++ b/source3/smbd/utmp.c
@@ -472,22 +472,23 @@ static int ut_id_encode(int i, char *fourbyte)
int nbase;
const char *ut_id_encstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- fourbyte[0] = 'S';
- fourbyte[1] = 'M';
-
/*
- * Encode remaining 2 bytes from 'i'.
* 'ut_id_encstr' is the character set on which modulo arithmetic is done.
* Example: digits would produce the base-10 numbers from '001'.
*/
nbase = strlen(ut_id_encstr);
+ fourbyte[0] = ut_id_encstr[i % nbase];
+ i /= nbase;
+ fourbyte[1] = ut_id_encstr[i % nbase];
+ i /= nbase;
fourbyte[3] = ut_id_encstr[i % nbase];
i /= nbase;
fourbyte[2] = ut_id_encstr[i % nbase];
i /= nbase;
- return(i); /* 0: good; else overflow */
+ /* we do not care about overflows as i is a random number */
+ return 0;
}
#endif /* defined(HAVE_UT_UT_ID) */
@@ -517,11 +518,6 @@ static bool sys_utmp_fill(struct utmp *u,
* ut_line:
* If size limit proves troublesome, then perhaps use "ut_id_encode()".
*/
- if (strlen(id_str) > sizeof(u->ut_line)) {
- DEBUG(1,("id_str [%s] is too long for %lu char utmp field\n",
- id_str, (unsigned long)sizeof(u->ut_line)));
- return False;
- }
utmp_strcpy(u->ut_line, id_str, sizeof(u->ut_line));
#if defined(HAVE_UT_UT_PID)