Re: [Samba] Closing sessions and smbstatus

2008-10-21 Thread Jeremy Allison
On Tue, Oct 21, 2008 at 12:21:12AM -0200, Norberto Bensa wrote:
 Quoting Jeremy Allison [EMAIL PROTECTED]:

 On Mon, Oct 20, 2008 at 10:03:46PM -0200, Norberto Bensa wrote:
 Locked files:
 Pid  UidDenyMode   Access  R/WOplock
  SharePath   Name   Time
 --
 747  4036   DENY_ALL   0x2019f RDWR   NONE
  /home/mjoddone   .Correo/retina/addr2a3a.pmr   Thu Oct 16 17:44:15 2008

 Can you gdb and break at print_share_mode()
 and see why the call at :

 Hm. I'm affraid I don't know gdb good enough, and BTW, and correct me if 
 I'm wrong, but shouldn't I be running a debug-enabled binary of  
 smbstatus to do what you're asking me for?

Yes, but I already assumed that, sorry :-).
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


RE: [Samba] Closing sessions and smbstatus

2008-10-21 Thread Rippl, Steve
 On Mon, Oct 20, 2008 at 12:52:57PM -0700, Steve Rippl wrote:
 
  But checking our server I find that the processes DO still exist!
So
  I'm getting a user session in smbstatus with a specific PID and when
I
  ps -ef | grep PID there is the smbd process still running, yet the
user
  has long since logged out (days ago)?!  It's not just that the .tbd
file
  hasn't been updated, it's that the /usr/local/bin/smbd process is
still
  running.  A restart of Samba clears them all up immediately, but why
are
  they hanging around when the client is gone?  Is this just happening
to
  me on our particular setup or is this normal behavior?
 
 No, that's not normal behavior, but it does explain why
 the session id's are hanging around. Once the client
 terminates the TCP session the smbd should die (and
 clean up all resources such as session id's etc.).
 
 When you find a process in this state attach using
 strace -p pid (on Linux) to see what it's up to.
 
 Jeremy.

So after one day I have ~50 left-over sessions.  Running strace as above
I seem to usually get...

select(32, [5 23 31], [], NULL, {43, 45}) = 0 (Timeout)
gettimeofday({1224652458, 61107}, NULL) = 0
geteuid()   = 0
getegid()   = 0
setgroups(0, [])= 0
setresgid(4294967295, 0, 4294967295)= 0
getegid()   = 0
setresuid(0, 0, 4294967295) = 0
geteuid()   = 0
write(23, \205\0\0\0, 4)  = 4
gettimeofday({1224652458, 61549}, NULL) = 0
geteuid()   = 0
fstat(25, {st_mode=S_IFREG|0644, st_size=894111, ...}) = 0
gettimeofday({1224652458, 61698}, NULL) = 0
select(32, [5 23 31], [], NULL, {60, 0} unfinished ...

although a couple of time I got more go by...

...[cut-off]...
getegid()   = 0
setgroups(0, [])= 0
setresgid(4294967295, 0, 4294967295)= 0
getegid()   = 0
setresuid(0, 0, 4294967295) = 0
geteuid()   = 0
fcntl(8, F_SETLKW, {type=F_RDLCK, whence=SEEK_SET, start=244, len=1}) =
0
fcntl(8, F_SETLKW, {type=F_UNLCK, whence=SEEK_SET, start=244, len=1}) =
0
stat(/etc/pam.d, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open(/etc/pam.d/samba, O_RDONLY)  = 25
fstat(25, {st_mode=S_IFREG|0644, st_size=69, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f2f8db98000
read(25, @include [EMAIL PROTECTED] co..., 4096) = 69
stat(/etc/pam.d, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open(/etc/pam.d/common-auth, O_RDONLY) = 29
fstat(29, {st_mode=S_IFREG|0644, st_size=484, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f2f8db97000
read(29, #\n# /etc/pam.d/common-auth - aut..., 4096) = 484
open(/lib/security/pam_unix.so, O_RDONLY) = 30
read(30, \177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\0\1\0\0\0\260*\0\0...,
832) = 832
fstat(30, {st_mode=S_IFREG|0644, st_size=50568, ...}) = 0
mmap(NULL, 2195080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 30,
0) = 0x7f2f892fd000
mprotect(0x7f2f89309000, 2093056, PROT_NONE) = 0
mmap(0x7f2f89508000, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 30, 0xb000) = 0x7f2f89508000
mmap(0x7f2f89509000, 48776, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2f89509000
close(30)   = 0
open(/etc/ld.so.cache, O_RDONLY)  = 30
fstat(30, {st_mode=S_IFREG|0644, st_size=45774, ...}) = 0
mmap(NULL, 45774, PROT_READ, MAP_PRIVATE, 30, 0) = 0x7f2f8db8b000
close(30)   = 0
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or
directory)
open(/lib/libselinux.so.1, O_RDONLY)  = 30
read(30, \177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\0\1\0\0\0\240Q\0\0...,
832) = 832
fstat(30, {st_mode=S_IFREG|0644, st_size=109368, ...}) = 0
mmap(NULL, 2209176, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 30,
0) = 0x7f2f888d4000
mprotect(0x7f2f888ed000, 2097152, PROT_NONE) = 0
mmap(0x7f2f88aed000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 30, 0x19000) = 0x7f2f88aed000
mmap(0x7f2f88aef000, 1432, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f2f88aef000
close(30)   = 0
open(/etc/selinux/config, O_RDONLY)   = -1 ENOENT (No such file or
directory)
statfs(/selinux, 0x7fff960e0250)  = -1 ENOENT (No such file or
directory)
open(/proc/mounts, O_RDONLY)  = 30
fstat(30, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f2f8db8a000
read(30, rootfs / rootfs rw 0 0\nnone /sys..., 1024) = 1024
read(30, dered 0 0\n/dev/mapper/group-mate..., 1024) = 649
read(30, , 1024)  = 0
close(30)   = 0
munmap(0x7f2f8db8a000, 4096)= 0
munmap(0x7f2f8db8b000, 45774)   = 0

Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Vlastimil Šetka



Hi,

When are client sessions closed?  


Let me explain what I'm trying to do...  we're in a School district and
we try to stop kids logging more than once.  They way I did this before
was to dump the active sessions from our previous Server2003 fileserver
into a file once a minute and process it with a Perl script to check who
was connected from where, rebooting machines remotely as needed!  This
work well enough with the odd 'hung' session causing minor problems.
  
I'm in exactly the same situation. The school, PDC for ~100 computers, 
hundreds of users.
We need to track the logon / logoff. I can't find any usable tools so I 
made my own system.
I found that most reliable is the smbstatus output. Windows do strange 
thinks with connections during domain logons so use of preexec script is 
complicated.
By the Perl script I run smbstatus every 5 seconds, scan the changes 
from previous run and write it to the MySQL DB. That's all woks fine.

So now I'm trying to do the same thing with our new Samba (3.0.31)
fileserver using the output from smbstatus.  However, in many cases
sessions are still in there long after the user has logged out of the
machine.  I'm even seeing two sessions for different people on the same
machine with the same pid number!  How is this working?  Why are not all
sessions ending when the user logs off?  Am I going to be able to use
this for what I'm trying to do?!!
  

I have some problems with this too. See this thread:
 [Samba] smbstatus - switched off computers are sometimes showed
 http://lists.samba.org/archive/samba/2008-September/143701.html

Now I get some new experience with it. The main problem is that samba 
sometimes doesn't update the sessionid.tdb file when the process exits. 
This records is not showed in smbstatus output, because smbstatus checks 
if the PID exists. I patched the smbstatus so it showed me that there is 
the records with no related PID. Then, maybe after 1 day or so, this PID 
is used for other proccess and I can see the ghost logon in my 
tracking system (and in most cases logoff at next run - after 5 seconds).
On the list is now the thread [Samba] processes not closing where is 
described some self-repair function related do sessionid.tdf file. The 
samba process when writing to this file should check all records and 
delete it if the PID doesn't exist. It will be nice but In my situation 
it doesn't work. Maybe it's because of Samba version (3.0.24, official 
Debian Etch package).


The most strange think I've seen is that I get some fake logon records 
for one user day-by-day at the same time. Let say [EMAIL PROTECTED] - tracked 
logon at tuesday 14:10:12, then at the same time at wednesday and 
thursday. In fact the COMP1 is switched off or other user is loged on at 
the time. The USER1 were loged on the COMP1 at monday.

The fileserver itself is working great, we have over 2000 users happily
using it with less problems than we had on the Windows box.  I really
appreciate all the work the Samba team does!
  
The same experience. Samba-based solution with one PDC is rock-stable 
for us in comparsion with several Windows 2003 AD servers running before.

Many thanks,

Steve Rippl
Woodland School District
  

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Steve Rippl

On Mon, 2008-10-20 at 21:10 +0200, Vlastimil Šetka wrote:
  Hi,
 
  When are client sessions closed?  
 
  Let me explain what I'm trying to do...  we're in a School district and
  we try to stop kids logging more than once.  They way I did this before
  was to dump the active sessions from our previous Server2003 fileserver
  into a file once a minute and process it with a Perl script to check who
  was connected from where, rebooting machines remotely as needed!  This
  work well enough with the odd 'hung' session causing minor problems.

 I'm in exactly the same situation. The school, PDC for ~100 computers, 
 hundreds of users.
 We need to track the logon / logoff. I can't find any usable tools so I 
 made my own system.
 I found that most reliable is the smbstatus output. Windows do strange 
 thinks with connections during domain logons so use of preexec script is 
 complicated.
 By the Perl script I run smbstatus every 5 seconds, scan the changes 
 from previous run and write it to the MySQL DB. That's all woks fine.
  So now I'm trying to do the same thing with our new Samba (3.0.31)
  fileserver using the output from smbstatus.  However, in many cases
  sessions are still in there long after the user has logged out of the
  machine.  I'm even seeing two sessions for different people on the same
  machine with the same pid number!  How is this working?  Why are not all
  sessions ending when the user logs off?  Am I going to be able to use
  this for what I'm trying to do?!!

 I have some problems with this too. See this thread:
   [Samba] smbstatus - switched off computers are sometimes showed
   http://lists.samba.org/archive/samba/2008-September/143701.html
 
 Now I get some new experience with it. The main problem is that samba 
 sometimes doesn't update the sessionid.tdb file when the process exits. 
 This records is not showed in smbstatus output, because smbstatus checks 
 if the PID exists. I patched the smbstatus so it showed me that there is 
 the records with no related PID. Then, maybe after 1 day or so, this PID 
 is used for other proccess and I can see the ghost logon in my 
 tracking system (and in most cases logoff at next run - after 5 seconds).
 On the list is now the thread [Samba] processes not closing where is 
 described some self-repair function related do sessionid.tdf file. The 
 samba process when writing to this file should check all records and 
 delete it if the PID doesn't exist. It will be nice but In my situation 
 it doesn't work. Maybe it's because of Samba version (3.0.24, official 
 Debian Etch package).

But checking our server I find that the processes DO still exist!  So
I'm getting a user session in smbstatus with a specific PID and when I
ps -ef | grep PID there is the smbd process still running, yet the user
has long since logged out (days ago)?!  It's not just that the .tbd file
hasn't been updated, it's that the /usr/local/bin/smbd process is still
running.  A restart of Samba clears them all up immediately, but why are
they hanging around when the client is gone?  Is this just happening to
me on our particular setup or is this normal behavior?

Thanks.
--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Vlastimil Šetka



But checking our server I find that the processes DO still exist!  So
I'm getting a user session in smbstatus with a specific PID and when I
ps -ef | grep PID there is the smbd process still running, yet the user
has long since logged out (days ago)?!  It's not just that the .tbd file
hasn't been updated, it's that the /usr/local/bin/smbd process is still
running.  A restart of Samba clears them all up immediately, but why are
they hanging around when the client is gone?  Is this just happening to
me on our particular setup or is this normal behavior?
  
We have ~400 logons per day. Sometimes (average 1 process per day) some 
processes hangs - the PID exists but user is several hours loged off. In 
this time other users were loged on this station... But there are some 
locked files connected with this PID - I think this is because the 
process isn'n closed.
Can you see some locked files connected with the bogus PID in smbstatus 
output?

Thanks.
  

--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Jeremy Allison
On Mon, Oct 20, 2008 at 12:52:57PM -0700, Steve Rippl wrote:

 But checking our server I find that the processes DO still exist!  So
 I'm getting a user session in smbstatus with a specific PID and when I
 ps -ef | grep PID there is the smbd process still running, yet the user
 has long since logged out (days ago)?!  It's not just that the .tbd file
 hasn't been updated, it's that the /usr/local/bin/smbd process is still
 running.  A restart of Samba clears them all up immediately, but why are
 they hanging around when the client is gone?  Is this just happening to
 me on our particular setup or is this normal behavior?

No, that's not normal behavior, but it does explain why
the session id's are hanging around. Once the client
terminates the TCP session the smbd should die (and
clean up all resources such as session id's etc.).

When you find a process in this state attach using
strace -p pid (on Linux) to see what it's up to.

Jeremy.
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Norberto Bensa
Hello list,

On Monday October 20 2008 18:01:10 Jeremy Allison wrote:
 On Mon, Oct 20, 2008 at 12:52:57PM -0700, Steve Rippl wrote:
  Is this just happening to
  me on our particular setup or is this normal behavior?

I'm having this problem too. Ubuntu 8.04.1. Samba 3.0.28A (IIRC)


 No, that's not normal behavior,  

... [snip] ...

 When you find a process in this state attach using
 strace -p pid (on Linux) to see what it's up to.

I'll do tomorrow. and I'll report back.


 Jeremy.

Thanks!

Regards,
Norberto
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Norberto Bensa

Quoting Jeremy Allison [EMAIL PROTECTED]:


When you find a process in this state attach using
strace -p pid (on Linux) to see what it's up to.


[EMAIL PROTECTED]:~$ sudo smbstatus
Unknown parameter encountered: change notify timeout
Ignoring unknown parameter change notify timeout

Samba version 3.0.28a
PID Username  Group Machine
---

Service  pid machine   Connected at
---

Locked files:
Pid  UidDenyMode   Access  R/WOplock
SharePath   Name   Time

--
747  4036   DENY_ALL   0x2019f RDWR   NONE  
/home/mjoddone   .Correo/retina/addr2a3a.pmr   Thu Oct 16  
17:44:15 2008



[EMAIL PROTECTED]:~$ sudo strace -p 747
attach: ptrace(PTRACE_ATTACH, ...): No such process


I have no stale sessions. My problem seems different (my memory seems  
to be falling lately) I have stale locks.


Is that normal?


Thanks,
Norberto


This message was sent using IMP, the Internet Messaging Program.


--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Jeremy Allison
On Mon, Oct 20, 2008 at 10:03:46PM -0200, Norberto Bensa wrote:
 Quoting Jeremy Allison [EMAIL PROTECTED]:

 When you find a process in this state attach using
 strace -p pid (on Linux) to see what it's up to.

 [EMAIL PROTECTED]:~$ sudo smbstatus
 Unknown parameter encountered: change notify timeout
 Ignoring unknown parameter change notify timeout

 Samba version 3.0.28a
 PID Username  Group Machine
 ---

 Service  pid machine   Connected at
 ---

 Locked files:
 Pid  UidDenyMode   Access  R/WOplock  
  SharePath   Name   Time
 --
 747  4036   DENY_ALL   0x2019f RDWR   NONE
  /home/mjoddone   .Correo/retina/addr2a3a.pmr   Thu Oct 16 17:44:15 2008


 [EMAIL PROTECTED]:~$ sudo strace -p 747
 attach: ptrace(PTRACE_ATTACH, ...): No such process


 I have no stale sessions. My problem seems different (my memory seems to 
 be falling lately) I have stale locks.

 Is that normal?

Nope. The call process_exists_by_pid() should filter out
non-existant process id's before they get added into the
list.

In fact they are being so removed, which is why you
don't see them under the PID title above, and yet
the call to Ucrit_checkPid() is returning true for
some reason (which it shouldn't if the pid hasn't
been entered into the Ucrit_pid[] array).

Can you gdb and break at print_share_mode()
and see why the call at :

 if (Ucrit_checkPid(procid_to_pid(e-pid)))

is returning true in your case ?

Jeremy.
-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba


Re: [Samba] Closing sessions and smbstatus

2008-10-20 Thread Norberto Bensa

Quoting Jeremy Allison [EMAIL PROTECTED]:


On Mon, Oct 20, 2008 at 10:03:46PM -0200, Norberto Bensa wrote:

Locked files:
Pid  UidDenyMode   Access  R/WOplock
 SharePath   Name   Time
--
747  4036   DENY_ALL   0x2019f RDWR   NONE
 /home/mjoddone   .Correo/retina/addr2a3a.pmr   Thu Oct 16 17:44:15 2008


Can you gdb and break at print_share_mode()
and see why the call at :


Hm. I'm affraid I don't know gdb good enough, and BTW, and correct me  
if I'm wrong, but shouldn't I be running a debug-enabled binary of  
smbstatus to do what you're asking me for?


Thanks!
Norberto


This message was sent using IMP, the Internet Messaging Program.


--
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/listinfo/samba