patch for logon time on samba3.0 alpha22
Jianliang Lu
j.lu at tiesse.com
Wed Mar 19 14:38:56 GMT 2003
Hi,
I've patched the samba3.0 alpha22 for logon_time, now the user's logon time
is updated when he logs on successfully.
In attachment is the patch.
Jianliang Lu
TieSse s.p.a.
j.lu at tiesse.com
luj at libero.it
-------------- next part --------------
--- samba-3.0alpha22/source/smbd/session.c Wed Mar 19 14:46:03 2003
+++ samba-3.0alpha22/source/smbd/session.c.fix Wed Mar 19 14:45:35 2003
@@ -41,6 +41,9 @@
int tdb_store_flag; /* If using utmp, we do an inital 'lock hold' store,
but we don't need this if we are just using the
(unique) pid/vuid combination */
+ SAM_ACCOUNT *sampass=NULL;
+ BOOL ret;
+
vuser->session_keystr = NULL;
@@ -140,6 +143,34 @@
}
#endif
+ if (!NT_STATUS_IS_OK(pdb_init_sam (&sampass))) {
+ return -1;
+ }
+ become_root();
+ ret = pdb_getsampwnam(sampass, sessionid.username);
+ unbecome_root();
+
+ if (ret==False) {
+ DEBUG(0, ("session.c : Username %s not found!\n", sessionid.username));
+ pdb_free_sam(&sampass);
+ return -1;
+ }
+
+ if (!pdb_set_logon_time(sampass, time(NULL), PDB_CHANGED))
+ DEBUG(0, ("session.c : pdb_set_logon_time fialed!\n"));
+
+ /* Now write it into the file. */
+ become_root();
+ ret = pdb_update_sam_account (sampass);
+ unbecome_root();
+ if (ret==False) {
+ DEBUG(0, ("session.c : pdb_update_sam_account failed! \n"));
+ pdb_free_sam(&sampass);
+ return -1;
+ }
+
+ pdb_free_sam(&sampass);
+
vuser->session_keystr = strdup(keystr);
if (!vuser->session_keystr) {
DEBUG(0, ("session_claim: strdup() failed for session_keystr\n"));
More information about the samba-technical
mailing list