• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Apply User and Groups to Items in a Folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Apply User and Groups to Items in a Folder


  • Subject: Re: Apply User and Groups to Items in a Folder
  • From: "Laine Lee" <email@hidden>
  • Date: Wed, 19 Apr 2006 22:02:54 -0500

On 4/19/06 7:31 PM, "Todd Geist" <email@hidden> wrote:

> On Apr 19, 2006, at 5:11 PM, Paul Berkowitz wrote:
>
>> On 4/19/06 4:26 PM, "Todd Geist" <email@hidden>
>> wrote:
>>>
>>>
>>> Nothing works I always get the password dialog.  As far as I can tell
>>> "administrator privileges" doesn't do anything.
>>
>> Which OS are you at?
>
> 10.4.6
>

Here's something to mull over. This can help you store a password in a safer way than some. Some people believe there is no adequately safe way to store a password. You get a script that needs admin privileges and you quote it properly (I recommend Smile's "Make an Applescript String"), then you insert it into the place provided in the script. What the script does is create a version of your script that contains an obfuscated version of your admin password and calls it when needed. There are two versions of the compile command script line (the command that creates the script you want), one that creates the finished run-only version and one that creates a version you can edit for testing. You play with it in editable mode by leaving the run-only version of that line commented, and once the editable version is working, you comment the version of the compile command line that creates the editable version of the script and uncomment the version of the compile command line that c!
 reates the run-only version. It's pretty hard to get any useful information out of that run-only version. You have to decide whether it's hard enough to make the solution worth while.

property patternpop : ""
property iterationSet : {}

set current_user to (do shell script "id -un")
set store_target to ("/Users/" & current_user & "/Library/Scripts/Utility")
try
    do shell script "mkdir -p" & space & store_target
end try
set generatedscptname to text returned of (display dialog "Enter a name for the Authentication Agent script:" default answer "Authentication Agent")
do shell script "touch" & space & (quoted form of (store_target & "/" & generatedscptname & ".scpt"))
set the_runonlyscript to POSIX file (store_target & "/" & generatedscptname & ".scpt") as alias
set patternpop to text returned of (display dialog "Enter a number between 10 and 10,000:" default answer "42")
set the hexData to system attribute "sysv"
set hexString to {}
repeat 4 times
    set hexString to ((hexData mod 16) as string) & hexString
    set hexData to hexData div 16
end repeat
set the OSVersion to the hexString as string
if OSVersion < 1040 then
    set _letters to text returned of (display dialog "Enter the password. Your typing will be visible." default answer "")
else
    set _letters to text returned of (display dialog "Enter the password:" default answer "" with hidden answer)
end if
set iterationSet to obfu(_letters)

set authscript to "
property i : \"UserNotificationCenter\"
property theword : missing value
property passwd : missing value
property iterationSet :" & space & (iterationSet as text) & "

set appath to path to Çconstant afdregfpÈ as string
set appinfo to info for (appath as alias)
set AppName to displayed name of appinfo
set passwd to iterate(iterationset)

--(Your script goes here. Use statements such as \"execute foo password passwd with administrator privileges\".)
Display dialog \"Agent!\"


set passwd to \"\"
on iterate(iterationset)
set iterationCount to " & patternpop & "
set the_word to \"\"
repeat with anItem in iterationSet
    set the_word to the_word & (ASCII character (anItem - iterationCount))
end repeat
return the_word
end iterate
"

set write_mountdest to the_runonlyscript
set write_mountdata to authscript
write_to_file(write_mountdest, write_mountdata)
--The following line will create a run only version of the authentication agent
do shell script "osacompile" & space & "-o" & space & (quoted form of (store_target & "/" & generatedscptname & ".scpt")) & space & "-dx" & space & (quoted form of (store_target & "/" & generatedscptname & ".scpt"))
--The following line will create an editable version of the authentication agent. You can use it for troubleshooting, if needed.
--do shell script "osacompile" & space & "-o" & space & (quoted form of (store_target & "/" & generatedscptname & ".scpt")) & space & "-d" & space & (quoted form of (store_target & "/" & generatedscptname & ".scpt"))

display dialog "Your script has been created in the Utility folder of your Scripts folder. You can launch it from the Script menu, or, if you have FastScripts, you can trigger it with a keyboard shortcut." buttons {"OK"} default button 1 giving up after 10

on tid(s)
    set my text item delimiters to s
end tid

on obfu(anypass)
    set mountpass to "{"
    repeat with aletter in anypass
        set mountpass to mountpass & ((ASCII number of aletter) + patternpop) & ", "
    end repeat
    set mountpass to (items 1 thru -3 of mountpass) & "}" as text
    return mountpass
end obfu

on write_to_file(the_file, the_data)
    try
        open for access the_file with write permission
        set eof of the_file to 0
        write (the_data as string) to the_file
        close access the_file
    on error therr
        try
            close access the_file
        end try
        display dialog therr
    end try
end write_to_file


--
Laine Lee
email@hidden
http://lonestar.utsa.edu/llee
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Apply User and Groups to Items in a Folder
      • From: "John C. Welch" <email@hidden>
    • Re: Apply User and Groups to Items in a Folder
      • From: Laine Lee <email@hidden>
  • Prev by Date: Re: Apply User and Groups to Items in a Folder
  • Next by Date: Re: Apply User and Groups to Items in a Folder
  • Previous by thread: Re: Apply User and Groups to Items in a Folder
  • Next by thread: Re: Apply User and Groups to Items in a Folder
  • Index(es):
    • Date
    • Thread