I want to check, if a user has access rights to a certain samba-share. I'm currently doing this using the command smbclient
in Version 4.3.11-Ubuntu
.
Apparently it is not a good idea to use the exit
status for evaluation of success, as described in this question: Exit codes of smbclient
But nevertheless I have some strange behaviour. I get different exit status when calling the program with Perls system
function.
perldoc -f system
tells me this:
The return value is the exit status of the program as returned by the "wait" call.
When calling from commandline I get EXIT 1
user@host:~$ smbclient //server/share MyFalsePassword --user=any.user -c "cd somefolder;"; echo "EXIT $?"
WARNING: The "syslog" option is deprecated
session setup failed: NT_STATUS_LOGON_FAILURE
EXIT 1
Calling the same whitin Perl I get EXIT 256
.
user@host:~$ perl -E 'say "EXIT " . system("smbclient //server/share MyFalsePassword --user=any.user -c \"cd somefolder;\"");'
WARNING: The "syslog" option is deprecated
session setup failed: NT_STATUS_LOGON_FAILURE
EXIT 256
I also have the value 256
in the variable $?
whitin Perl.
Note: I get EXIT 0
in both (Bash and Perl) if I use the correct credentials.
My question: Why do I get different exit status from Bash and Perl if I use wrong credentials? How do I check correctly?
I use Perl v5.22 on Ubuntu 16.04.