Adding a folder structure to a folder owned bij another user.

Gents,

I have a daemon running at which users, using a tool, can add information.
The daemon convert this information to information files in a predefined folder structure, choosen by the user.
Each user can choose from a number of predefined folder structures.

Till now the manager of the user group, ask an administrator to set this up.

The ‘Repository’ folder is owned by a special User ‘RepoTechLab’ and Group ‘RepoTechLab’.
User RepoTechLab read and write
Group RepoTechLab read only
Everybody noaccess

No one should and can look at the data directly.
Everything happens by using the Tool and daemon.
This works perfect.

For the future I want that the user can choose and setup the structure by them self.

I did try several things but my main problem is this.
How can I use applescript or bash script, so that a normal user starts that script, which can go into the Repository folder and create the folder structure.

To test this action I did try

do shell script "mkdir /Volumes/Repository/test" user name "RepoTechLab" password "********"

but didn’t work. I get mkdir: /Volumes/Repository/test: Permission denied

But is this the direction to go?

Thanks

rva

Hi,

you should add with administrator privileges


do shell script "mkdir /Volumes/Repository/test" user name "RepoTechLab" password "********" with administrator privileges

Hi StefanK

Thank you for your reply,

However, the RepoTechDev user and group have no admin rights, so adding ‘with administrator privileges’ will not work.

Any other idea’s or suggestions?

rva

when you run this and then enter your password in the administrator dialog box, what error do you get?

do shell script "mkdir -p " & " /Volumes/Repository/NEW_TEST" with administrator privileges

try this too…

do shell script "mkdir -p " & " /Volumes/Repository/NEW_TEST" password " ¢¢¢¢¢¢¢" with administrator privileges

Hi TomX

Thanks you, for your reply.
However, maybe I was unclear with this line

“However, the RepoTechDev user and group have no admin rights, so adding ‘with administrator privileges’ will not work.”

This should read as “so adding ‘with administrator privileges’ will not work, because of the admin password is then in the open”.

I dont mind to let the password of user RepoTechDev inside the script, because I will cut it in pieces or, if possible, try to use a sudoers list with something like
RepoTechDev ALL=NOPASSWD:/Volumes/…/…/MyScript, if that works on automator files or and applescript files!

Sorry about the confusion.

More suggestions?

rva

This problem is solved after reading about the keychain scripting dict.

In case if someone interested, this is what I come up with as POC and is quick and dirty and any comment is welcome on that. If you want to try this, create a RepoKey in your KeyChain ( funny, I have to let the script launch keychain otherwise it takes along time, but thats for later ).

set accesskey to "RepoPW"
set repoPW to GetPasswordFromKeychain(accesskey)
if repoPW is not null then
	try
                -- still no access
		do shell script "mkdir -p " & " /Volumes/Repository/NEW_TEST" user name "_svn" password repoPW
	on error
		display dialog "Creation of your choosen Structure failed ( Service Desk is notified ).
	  
	   Contact your Repository Manager, or call the Service Desk. " buttons {"OK"} default button "OK" with icon 0 with title "Abort - Error notification"
		-- return null
	end try
else
	-- return null
	quit
end if

-- GET PASSWORD USING KEYCHAIN ACCESS
on GetPasswordFromKeychain(pwKey)
	tell application "Keychain Scripting"
		launch
		try
			tell keychain "System.keychain"
				return password of some key whose name is pwKey
			end tell
		on error
			display dialog "No correct keychain item found to continue ( Service Desk is notified ).
	  
	   Contact your Repository Manager, or call the Service Desk. " buttons {"OK"} default button "OK" with icon 0 with title "Abort - Error notification"
			return null
		end try
	end tell
end GetPasswordFromKeychain

[b]

But, my original question is still standing.[/b]

Any help is appreciated

thanks

rva

edit - did put launch inside the code otherwise it cant find the key.

This is what I came up with and works for the moment.


do shell script "echo " & repoPW & " | sudo -S -u RepoTechLab mkdir -p " & " /Volumes/Repository/NEW_TEST"

However, this works for some account, but for others not, then it doesn’t accept the passw 3 times and tells sorry and about not in sudo list error.

Help :confused:

rva