[Casper] run script as different user?
Ryan Harter
rharter at uwsp.edu
Wed Aug 20 11:45:57 PDT 2008
Since these scripts are being run in the root context you should be
able to run commands with su without being prompted. The trick is
that you will not be able to just run 'su $user' and then list the
commands after that, you will have to run 'su $user -c "command to
run"' for every command you need to run. We currently do this with
several scripts that we run, including one that chown's files (for
roving profiles) just like you are trying to do. For us, the script
would look like this:
for i in $( ls /Users )
do
su $i -c "defaults write /Users/$i/Library/Preferences/
com.panic.Transmit3 SerialNumber 333-333-333-333"
done
Like I said, we do similar things and, as long as we are running
individual commands with the -c parameter, it works fine with no
promts. Note that this is only the case if you are running this as
root, an administrator account will not be able to su without prompts.
Hope it helps.
Ryan Harter
UW - Stevens Point
Workstation Developer
715.346.2716
Ryan.Harter at uwsp.edu
On Aug 20, 2008, at 12:31 PM, Jeremy Matthews wrote:
> You know, the funny thing is that we tried that but our test machine
> wouldn't respect the command.
>
> I'm guessing at this point that since the script has a lot more
> running inside of it, it needs further dissasembly....something must
> be silently failing or changing it back. I know at one point we had
> a pseudo-security daemon that looked for new files, and would change
> them in whatever way that consultant saw fit (before my time).
>
> But, we have re-run ownership (standalone) and it does fix the
> issue. I think the set of setup scripts we "inherited" may
> need....further study.
>
> Thanks,
> j
>
> On Aug 20, 2008, at 1:27 PM, Miles Leacy wrote:
>
>> On Wed, Aug 20, 2008 at 1:22 PM, Jeremy Matthews <jeremymatthews at mac.com
>> > wrote:
>> Thomas,
>>
>> We used a wild card...or at last, what I thought was a wild card:
>> ----
>> for i in $( ls /Users )
>> do
>> defaults write /Users/$i/Library/Preferences/com.panic.Transmit3
>> SerialNumber 333-333-333-333
>> done
>> ----
>>
>> Unfortunately, this runs as root, so permissions get horked, etc.
>>
>> Add the line:
>> chown $i /Users/$i/Library/Preferences/com.panic.Transmit3.plist
>>
>> before the "done" statement.
>>
>> ta-daa! your users' plist now belongs to them.
>>
>
> <ATT00001.txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.jamfsoftware.com/pipermail/casper/attachments/20080820/a4318a8d/attachment.html
More information about the Casper
mailing list