gniemetz / automount

Mount shares at login
MIT License
40 stars 6 forks source link

Support for the Domain username #6

Closed RiccardoSaettone closed 7 years ago

RiccardoSaettone commented 7 years ago

My NAS is in a Domain so my username when I mount a share is something like domain\username. but when i configure my .plist with something like

`Account

mydomain\myusername` I have this error `bash-3.2$ /usr/local/bin/automount.sh -m /Users/********/Library/Preferences/it.niemetz.automount.plist or /Users/********/Library/Keychains/login.keychain are missing bash-3.2$ chown ${USER}:staff /usr/local/bin/automount.sh` I think that special characters like \ and @ aren't support for login name, is something similar of the "bug" of sadrian80 with the special characters in the password,
RiccardoSaettone commented 7 years ago

I think that this can help you:

I found that if i try to mount the NAS in terminal in must change the \ between Domain and username with a ; practically mount_smbfs -o soft,nodev,nosuid 'smb://myDomain\ myUsername@myNAS/TEST' /Users/*******/Volumes/TEST DOESN'T WORK

But if i change myDomain\myUsername with myDomain;myUsername mount_smbfs -o soft,nodev,nosuid 'smb://myDomain;myUsername@myNAS/TEST /Users/*******/Volumes/TEST everything works correctly

So i change my .plist Account string from: myDomain\myUsername to myDomain;myUsername

and add a new keychain entry

/usr/local/bin/automount.sh --addpassword --account='myDomain;myUsername' --server=myNAS --protocol=smb

The ' ' in the --account are mandatory otherwise the character ; will not be accepted

Now all works.

gniemetz commented 7 years ago

I'll take a look and post back

Thank you

RiccardoSaettone commented 7 years ago

I test the last version 0.90.18, but doesn't work the password is taken correctly from the keychain, and also the domain an the username from del .plst file, but when the script end I have this error in the log

sudo /usr/local/bin/automount.sh -m mount of MYSHARE failed (RC=1, RV=) automount runned with errors. and the volume is not mounted

This is a extract of the debug, I hope this can help

+++(/usr/local/bin/automount.sh:416): getPasswordFromKeychain(): security find-internet-password -w -r 'smb ' -a MYUSER -l MYNAS -j automount /Users/MACUSER/Library/Keychains/login.keychain-db +++(/usr/local/bin/automount.sh:425): getPasswordFromKeychain(): _RC=0 +++(/usr/local/bin/automount.sh:427): getPasswordFromKeychain(): '[' 0 -ne 0 ']' +++(/usr/local/bin/automount.sh:430): getPasswordFromKeychain(): return 0 ++(/usr/local/bin/automount.sh:710): processMountlist(): launchctl asuser 501 chroot -u 501 -g 20 / expect -c ' set timeout 30 log_user 1 spawn /sbin/mount_smbfs -o soft,nodev,nosuid //MYNAS/MYSHARE /Users/MACUSER/Volumes/MYSHARE expect { "ser:" { if {"MYNAS" == ""} { send -- “MYNASUSER\r” } else { send -- “MYDOMAIN;MYNASUSER\r" } exp_continue } "sword:" { send -- “MYPASSWORD\r” exp_continue } timeout { exit 1 } eof { return } } catch wait result exit [lindex $result 3]' +(/usr/local/bin/automount.sh:710): processMountlist(): _RV='spawn /sbin/mount_smbfs -o soft,nodev,nosuid //MYNAS/MYSHARE /Users/MACUSER/Volumes/MYSHARE Password for MYNAS: ' +(/usr/local/bin/automount.sh:711): processMountlist(): _RC=1 +(/usr/local/bin/automount.sh:740): processMountlist(): '[' 1 -eq 0 ']' +(/usr/local/bin/automount.sh:744): processMountlist(): log --priority=3 'mount of MYSHARE failed (RC=1, RV=spawn /sbin/mount_smbfs -o soft,nodev,nosuid //MYNAS/MYSHARE /Users/MACUSER/Volumes/MYSHARE Password for MYNAS: )'

gniemetz commented 7 years ago

It looks like you don't get asked about the user, only the password. Try to mount the filesystem manually as stated in the log: /sbin/mount_smbfs -o soft,nodev,nosuid //MYNAS/MYSHARE /Users/MACUSER/Volumes/MYSHARE and look at the response you get from the command. It should ask for a user (expect "ser:") and for the password (expect "sword:")

RiccardoSaettone commented 7 years ago

I tried, and you're right, it asks me only the password:

/sbin/mount_smbfs -o soft,nodev,nosuid //MYNAS/MYSHARE /Users/MACUSER/Volumes/MYSHARE

Password for MyNAS:

"Password for MyNAS:" is exactly what is written on the terminal when it asks me for the password

after entering the password the shared folder is mounted correctly

gniemetz commented 7 years ago

Would you please try v0.90.19 from dev-branch if this error is fixed?

RiccardoSaettone commented 7 years ago

I tried, but don't work. When the script end I don't have error:

MYSHARE mounted successfully All shares mountd successfully.

But the shared folder are not mount.

This is a part of the debug log: I think that the there aren't ' ' at the start ed at the end of MYDOMAIN;MYNASUSER'

                    set timeout 30
                    log_user 1
                    spawn /sbin/mount_smbfs -o soft,nodev,nosuid //MYDOMAIN;MYNASUSER@MYNAS/MYSHARE /Users/MYMACUSER/Volumes/MYSHARE
                    expect {
                        -re "..*ser.*|.*name.*" {
                            if {"MYNAS" == ""} {
                                send -- "MYNASUSER\r"
                            } else {
                                send -- "MYDOMAIN;MYNASUSER\r"
                            }
                            exp_continue
                        }
                        -re ".*ssword.*" {
                            send -- “*****************r”
                            IN the place of the * There are something like \x00\x25\x54 the password converted in ex code i think
                            exp_continue
                        }
                        timeout {
                            exit 1
                        }
                        eof {
                            return
                        }
                    }
                    catch wait result
                    exit [lindex $result 3]'
+(/usr/local/bin/automount.sh:710): processMountlist(): _RV='spawn /sbin/mount_smbfs -o soft,nodev,nosuid //MYDOMAIN
invalid command name "MYNASUSER@MYNAS/MYSHARE"
    while executing
'MYNASUSER@MYNAS/MYSHARE /Users/MYMACUSER/Volumes/MYSHARE"
RiccardoSaettone commented 7 years ago

YES now it works Thanks

gniemetz commented 7 years ago

You're welcome :)