[Samba] smbmount not exiting
Joel Hammer
Joel at hammershome.com
Thu Oct 2 01:24:25 GMT 2003
I find when calling a program from a bash script, the bash script always
waits for the called program to return. This is normal behavior as I
understand it.
You have to use the & option to get the bash script to continue after
calling the program without the program exiting first.
eg.
!#/bin/bash
/bin/mount etc &
more statements.
Now, this won't return the exit code of your mount attempt
You may have to capture the output of the mount command with
/bin/mount etc > outputmessages 2>&1 &
and then examine the contents of outputmessages to see if you are mounted.
This could be a nuisance.
You could also capture the output with:
output=`/bin/mount/etc &`
and then examine the variable $output for strings suggesting success or
failure of the mount attempt.
Or, you could launch a daemon before you run the mount command.
The daemon would be a program which would run each second (sleep works
fine here) which checks for the mount and reports success, eg.
!#/bin/bash
while [ 1 -eq 1 ]
do
sleep 1
mount | grep \/mount\/dir
[ $? -eq 0 ] && {
echo Mounted successfully
exit
}
done
If you call this checker, this might work:
!#/bin/bash
checker &
mount etc
I am a big fan of simple scripts to solve simple problems.
Joel
On Thu, Oct 02, 2003 at 12:46:11AM +0200, Karin Spaink wrote:
>
> The following scriptlet, containing a wrong password among the
> mount options,
>
> #!/bin/bash
> /bin/mount -t smbfs -o \
> "netbiosname=mymachine,workgroup=group,username=user, \
> password=wrongpasswd,ro,debug=4" //machine/c /mnt/dir
> /bin/echo "Exit $?"
>
> returns invariably
>
> mount.smbfs started (version 2.2.7a-security-rollup-fix)
> added interface ip=192.168.0.53 bcast=192.168.0.255 nmask=255.255.255.0
> resolve_lmhosts: Attempting lmhosts lookup for name machine<0x20>
> getlmhostsent: lmhost entry: 127.0.0.1 localhost
> resolve_hosts: Attempting host lookup for name machine<0x20>
> Connecting to 192.168.0.50 at port 139
> 3457: session request ok
> 3457: session setup failed: ERRDOS - ERRnoaccess (Access denied.)
> SMB connection failed
> Exit 1
>
> However, the exact same code containing the right password
> hangs at the end of the line and doesn't return any exit code
> at all:
>
> #!/bin/bash
> /bin/mount -t smbfs -o \
> "netbiosname=mymachine,workgroup=group,username=user, \
> password=rightpasswd,ro,debug=4" //machine/c /mnt/dir
> /bin/echo "Exit $?"
>
> reports
>
> mount.smbfs started (version 2.2.7a-security-rollup-fix)
> added interface ip=192.168.0.53 bcast=192.168.0.255 nmask=255.255.255.0
> resolve_lmhosts: Attempting lmhosts lookup for name machine<0x20>
> getlmhostsent: lmhost entry: 127.0.0.1 localhost
> resolve_hosts: Attempting host lookup for name machine<0x20>
> Connecting to 192.168.0.50 at port 139
> 3472: session request ok
> 3472: session setup ok
> 3472: tconx ok
>
> That's all. The share is correctly mounted and accessible, but
> the script hangs forever waiting for mount/smbmount to exit.
>
> Substituting smbmount //machine/c /mnt/dir -o [same options]
> for the mount command makes absolutely no difference. Increasing
> the debug level to 10 gives no additional information after
> "tconx ok". The log contains entries like
>
> [2003/10/02 02:27:34, 0] client/smbmount.c:send_fs_socket(383)
> mount.smbfs: entering daemon mode for service \\machine\c, pid=3487
>
> and nothing else.
>
> Running mount with strace -v -f -s 128 gives the following:
>
> <snip endless normal-looking output>
>
> [pid 3493] open("/mnt/machine", O_RDONLY|O_LARGEFILE) = 6
> [pid 3493] ioctl(6, SMB_IOC_NEWCONN, 0xbfffd080) = 0
> [pid 3493] setsid() = 3493
> [pid 3493] kill(3492, SIGTERM) = 0
> [pid 3493] close(6) = 0
> [pid 3493] brk(0) = 0x811e000
> [pid 3493] brk(0) = 0x811e000
> [pid 3493] brk(0x80fe000) = 0x80fe000
> [pid 3493] brk(0) = 0x80fe000
> [pid 3493] close(3) = 0
> [pid 3493] open("/dev/null", O_WRONLY|O_LARGEFILE) = 3
> [pid 3493] getrlimit(0x7, 0xbfffd000) = 0
> [pid 3493] close(0) = 0
> [pid 3493] close(1) = 0
> [pid 3493] close(2) = 0
> [pid 3493] close(4) = 0
> [pid 3493] close(5) = 0
> [pid 3493] close(6) = -1 EBADF (Bad file descriptor)
> [pid 3493] close(7) = -1 EBADF (Bad file descriptor)
> [pid 3493] close(8) = -1 EBADF (Bad file descriptor)
> [pid 3493] close(9) = -1 EBADF (Bad file descriptor)
>
> <snip 1011 identical lines>
>
> [pid 3493] close(1021) = -1 EBADF (Bad file descriptor)
> [pid 3493] close(1022) = -1 EBADF (Bad file descriptor)
> [pid 3493] close(1023) = -1 EBADF (Bad file descriptor)
> [pid 3493] dup2(3, 1) = 1
> [pid 3493] dup2(3, 2) = 2
> [pid 3493] close(3) = 0
> [pid 3493] umask(022) = 022
> [pid 3493] open("/var/log/samba/smbmount.log",
> O_WRONLY|O_APPEND|O_CREAT|O_LARGEFILE, 0666) = 0
> [pid 3493] fstat64(0, {st_dev=makedev(3, 2), st_ino=32770,
> st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096,
> st_blocks=8, st_size=3221, st_atime=2003/10/02-02:28:44,
> st_mtime=2003/10/02-02:27:34, st_ctime=2003/10/02-02:27:34}) = 0
> [pid 3493] mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
> -1, 0) = 0x40018000
> [pid 3493] fstat64(0, {st_dev=makedev(3, 2), st_ino=32770,
> st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096,
> st_blocks=8, st_size=3221, st_atime=2003/10/02-02:28:44,
> st_mtime=2003/10/02-02:27:34, st_ctime=2003/10/02-02:27:34}) = 0
> [pid 3493] _llseek(0, 3221, [3221], SEEK_SET) = 0
> [pid 3493] munmap(0x40018000, 4096) = 0
> [pid 3493] umask(022) = 022
> [pid 3493] time(NULL) = 1065054607
> [pid 3493] geteuid32() = 0
> [pid 3493] write(0, "[2003/10/02 02:30:07, 0]
> client/smbmount.c:send_fs_socket(383)\n", 63) = 63
> [pid 3493] getpid() = 3493
> [pid 3493] geteuid32() = 0
> [pid 3493] write(0, " mount.smbfs: entering daemon mode for service
> \\\\machine\\c, pid=3493\n", 69) = 69
> [pid 3493] rt_sigaction(SIGUSR1, {0x804b150, [USR1], SA_RESTORER|SA_RESTART,
> 0x420276f8}, NULL, 8) = 0
> [pid 3493] pause(
>
> And there it stops.
>
> All of Samba comes from the Redhat 9 latest updated binary package,
> the system is a stock Redhat 9 with updates and the Windows host
> is an NT4sp6a machine.
>
> Any ideas anyone what could be wrong?
>
> Z
>
>
> --
> To unsubscribe from this list go to the following URL and read the
> instructions: http://lists.samba.org/mailman/listinfo/samba
More information about the samba
mailing list