Checking permissions of certain drivers at login with AppleScript?

Discussion in 'Mac Programming' started by Jessica Lares, Sep 26, 2015.

  1. Jessica Lares macrumors G3

    Jessica Lares

    Joined:
    Oct 31, 2009
    Location:
    Near Dallas, Texas, USA
    #1
    Hi there,

    I am using the iSlight disabler script from http://techslaves.org/isight-disabler/ on Yosemite. The reason being that I narrowed down the constant reboots with this one MacBook Pro to the camera. Now I would like it if I could have a script that runs at login checking whether or not permissions have changed due to Disk Utility or OS X updates.

    It would be great if it just silently checked each file and if everything's OK, then it doesn't do anything else. And if there are changes in the permissions, that it opens the disabler script to run it again.

    The drivers in question:

    Code:
    /System/Library/QuickTime/QuickTimeUSBVDCDigitizer.component/Contents/MacOS/QuickTimeUSBVDCDigitizer
    /System/Library/PrivateFrameworks/CoreMediaIOServicesPrivate.framework/Versions/A/Resources/VDC.plugin/Contents/MacOS/VDC
    /System/Library/PrivateFrameworks/CoreMediaIOServices.framework/Versions/A/Resources/VDC.plugin/Contents/MacOS/VDC
    /System/Library/Frameworks/CoreMediaIO.framework/Versions/A/Resources/VDC.plugin/Contents/MacOS/VDC
    /Library/CoreMediaIO/Plug-Ins/DAL/AppleCamera.plugin/Contents/MacOS/AppleCamera
    
    And it gets changed to chmod a-r, being a chmod a+r when it's enabled.

    If I could just get a link to somewhere that would explain how to do something like this, that would be fine.

    Thanks in advanced.
     
  2. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #2
    Hi,

    I obviously don't know the full background to this, but something about it just smells peculiar. I'll leave it to others to discuss whether disabling the iSight in this way is a good idea or not if they feel like it.

    In short, I gather that what you're asking is how to change the permissions on a number of files using AppleScript. For the record, you can do it like this:

    Code:
    do shell script "chmod a-r '/path/to/your/file/goes/here'"
    
    You can add the AppleScript to your login items so it kicks in whenever you log in. Or if you wanted to be fancy you could look into just executing a shell script at login, or on a schedule using Launch Services (https://developer.apple.com/library...l/BPSystemStartup/Chapters/ScheduledJobs.html)

    A word of warning - it might get a bit fiddly if you don't have permission to change those files. I've not taken a look at them on my system.

    Good luck
     
  3. Jessica Lares thread starter macrumors G3

    Jessica Lares

    Joined:
    Oct 31, 2009
    Location:
    Near Dallas, Texas, USA
    #3
    Yes, that is what I was asking for. Thank you. :)

    Adding to the iSight disabling issue... I've realized that the NVIDIA GeForce GT 330M graphics chip in this 2010 MacBook Pro (No, this is not the 2011 MBP in my signature) is probably the issue.

    The iSight camera probably gets initialized in the background, so that's when the discrete graphics kick in, and it happens randomly.

    I came to this conclusion after trying AfterShot and Pixelmator, which both lead to the machine shutting off within two minutes. So reading more into it, I then came across gfxCardStatus. Running that, confirmed the switch to the second graphics card was the issue.

    So obviously the iSight camera itself isn't the issue, but turning it off, has stopped the NVIDIA card from kicking in, with no obvious problems. We're talking about going from a hour of uptime to eighteen.

    Yes, when you run that script, it initially asks you for your admin password. In that original script it's this code:

    Code:
    do shell script "/bin/chmod a-r " & allDrivers with administrator privileges
    end if
    If I can just have the script check to see if the permissions are a-r, and finish if they are, then that would be perfect. That way it only asks for the password whenever I fix permissions or after updates for the most part.
     
  4. superscape macrumors 6502a

    superscape

    Joined:
    Feb 12, 2008
    Location:
    East Riding of Yorkshire, UK
    #4
    Hi,

    You can check the permissions of a file just by using ls. For example:

    Code:
    ls -l '/path/to/your/file'
    
    ...if you want to run that from AppleScript then its another case of using "do shell script"
     

Share This Page