4 Replies Latest reply: Oct 6, 2009 6:31 PM by Rick Anderson
Rick Anderson Level 2 Level 2 (165 points)
I just solved a network connectivity problem we've been having but the solution leaves me completely baffled. A little background first...

For the last few months, I've been working to keep a Mac in our system that carries out automated processing tasks connected to a number of network shares. I wrote a shell script that mounts the shares and I run it through launchd at login (and every 10 minutes to pick up any dropped connections.) When it runs though launchd, it produces "broken pipe" errors in the system log and it never connects to any shares. If I run the script from the command line, it connects, no errors.

After working through numerous theories about this, I discovered today that the script won't actually connect to the shares unless a Finder window is open that shows the icons of the shares.

This means the script works through launchd if I start it with this command:

*open /*

That pops open a Finder window and the shares subsequently connect just fine. If I leave that part out, no go. I get the "broken pipe" errors in the system log.

Can anyone explain to me why this is the case? I don't mind having to do that, but after several months of pulling my hair out, I'd at least like to have an understanding of what causes this.

The machine is running 10.5.8, btw.

Here's a snippet of the login script I'm running. Pretty basic stuff.

*mkdir '/Volumes/Pags'*
*mount_smbfs //bez-adv2/Pags /Volumes/Pags*
*mkdir '/Volumes/data'*
*mount_smbfs //bez-adv2/data /Volumes/data*
*mkdir '/Volumes/personal_folders'*
*mount_smbfs //bez-nwed/personal_folders /Volumes/personal_folders*

etc...

Message was edited by: Rick Anderson

Message was edited by: Rick Anderson

Message was edited by: Rick Anderson. Needed to clean up formatting of the script snippet I'd posted.

Mac OS X (10.5.8)
  • etresoft Level 7 Level 7 (26,600 points)
    First of all, is there something else in that script is that is Finder dependent? Do you have the specific user ids and passwords in the script to use when mounting?

    Finally, why not just use autofs for this and get rid of the launchd script altogether?
  • Rick Anderson Level 2 Level 2 (165 points)
    This is being run in an active directory environment so no user/passwords are needed. And as I said, if I run the script on the command line, it works. It seems to be a problem with running it in launchd.

    And I'm by no means an expert on autofs, but I was under the impression that it could not mount SMB shares (which is what I'm trying to connect to in this case.) Can autofs handle SMB? I looked into that as a possible solution at one point, but the stuff I ran across made it sound like it can't be used that way.
  • etresoft Level 7 Level 7 (26,600 points)
    Rick Anderson wrote:
    This is being run in an active directory environment so no user/passwords are needed. And as I said, if I run the script on the command line, it works. It seems to be a problem with running it in launchd.


    I know very little about Active Directory. What I think I know is that a Mac using Active Directory gets its user information from the network. If this is true, how would it know which Active Directory user to mount against when it is running under launchd, before any user has logged in?

    Usually mounts are user-specific. You don't want software engineers mounting //management/payroll.

    And I'm by no means an expert on autofs, but I was under the impression that it could not mount SMB shares (which is what I'm trying to connect to in this case.) Can autofs handle SMB?


    I was under a different impression. Try it.
  • Rick Anderson Level 2 Level 2 (165 points)
    I'll definitely look into it. I'd be happy to find out I'm wrong about that.

    I've been tinkering with the login script however, adding in a user name as part of the connection command and having some luck, but it's still not consistent. It seems to fail at login and sometimes succeed when the script runs again 10 minutes later.

    It's been in the back of my mind that maybe the machine is somehow failing to authenticate to Active Directory early enough in the process and maybe that's interfering with the ability to connect.

    Right after rebooting, I see a bunch of messages in the system log from DirectoryServices along these lines

    *enter machine password*

    /SourceCache/samba/samba-187/samba/source/libads/kerberos.c:adskinitpassword(228)

    *kerberoskinitpassword IPHONE-3@BEZ.DOMAINNAME.COM failed: Client not found in kerberos database*

    Funny thing is that iphone-3 is not the name of the machine where this is running. That's something else entirely.