Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GoGades

macrumors newbie
Original poster
Mar 1, 2008
4
0
Hello folks,

I'm building a simple app which needs to create and remove a samba share programaticly.

I was hoping I would just be able to stuff (or remove) the required directives in /etc/smb.conf but I see that Mac OS has a pretty sophisticated configuration system.

I've done a bunch of googling and didn't find a satisfactory answer. I would consider using AppleScript, although that seems pretty brittle.

Suggestions and/or links to relevant docs much appreciated. Thanks!
 
No offense, but sounds scary, as in the kind of thing a trojan might want to do.

Is this really the best way to achieve your goal? Whatever that may be.

AppleScript using the System Preferences seems to be the way to go though.

EDIT: However you do it, if you end up doing it, make it visible to the user what you are doing.

B
 
No offense, but sounds scary, as in the kind of thing a trojan might want to do.

Is this really the best way to achieve your goal? Whatever that may be.

AppleScript using the System Preferences seems to be the way to go though.

EDIT: However you do it, if you end up doing it, make it visible to the user what you are doing.

B

Of course - this is a commercial application...

"AppleScript using the System Preferences seems to be the way to go though. "

You say this based on what - that there are no API or command line tools to manipulate the sharing configurations, or is that just a guess?
 
You say this based on what - that there are no API or command line tools to manipulate the sharing configurations, or is that just a guess?

Exactly. The only exposed way to do this is via System Preferences -> Sharing -> File Sharing.

Doing it any other way you run the risk of stomping on the user's settings which would be a bad thing. (Unless of course this is an internal application in which case stomp away).

I've run into similar issues in Linux where making changes to the smb.conf file directly has confused the GUI admin tools so much that they become useless.

(BTW Just because it's a commercial app, doesn't mean this is the right way to achieve your goal.)

B
 
Exactly. The only exposed way to do this is via System Preferences -> Sharing -> File Sharing.

Uh, so much that...

net usershare add <sharename> <dirpath> does the trick from the CLI

man net provides oodles more info. Thanks for the help and advice.
 
Uh, so much that...

net usershare add <sharename> <dirpath> does the trick from the CLI

man net provides oodles more info. Thanks for the help and advice.

Sorry, my adventures in samba configuration predate version 3 and net, so I (obviously) didn't think of it.

Clearly someone else had a need similar to yours. :p I like the fact that it doesn't require root which alleviates my concerns.

Out of curiosity, does the share you create that way show up in System Preferences?

EDIT: Per the fine man page, you're still going to have to edit smb.conf to enable this (usershare is not enabled by default) and there is still a risk that you and the GUI will cross swords.

B
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.