How can you deny bash system access when sourcing a file?

I'm having another one of my "Linux noob" moments. This is probably easy to answer for the experienced bashers here.
I need a bash function to extract data from a PKGBUILD for use in other scripts. I want to write it in such a way that there is no significant risk when checking PKGBUILDs from possibly untrusted sources. It would be unreasonable to request the user to manually inspect every PKGBUILD when only extracting information (i.e. not building the package) and when dealing with many PKGBUILDs.
The function itself is very simple in the unsafe version:
for ARG in $@; do
source "$ARG"
echo "$pkgname $pkgver $pkgrel"
done
The reason that I want to source the file is to catch variable changes within the script (obviously missing the build function, but there are some that change outside of it). Parsing the file externally is likely to miss some changes.
How can I safely source the PKGBUILD? Ideally I want to completely limit access to the system, specifically the users home directory. Is there a way to do this as a user without write permissions? Is this what the "nobody" user is for?
I've considered using chroot but that appears to need root privileges. I want to avoid sudo.
Thanks.
Last edited by Xyne (2009-05-19 11:09:25)

Well, unsetting the PATH seems a good idea, but what if the pkgbuild contains sth like this:
pkgver=$(uname -r)
or any similar manner of dynamically generating one of the variables Xyne's interested in by using a command in a subshell? While the following works (i.e. fails as it should):
~$> OLDPATH=$PATH;export PATH="";/bin/bash -r -c 'foo=$(rm foo);foo=$(/bin/rm foo)';export PATH=$OLDPATH
/bin/bash: rm: No such file or directory
/bin/bash: /bin/rm: restricted: cannot specify `/' in command names
any legitimate use of command substitution will fail as well. Not to mention redirection, which is disabled in a restricted shell as well.
And yes, disabling (possibly) malicious bash builtins may be done as well, but it will fail as well if they are used in a legitimate way.
Using "nobody" also relies on the assumption that the user's files aren't world-writable. I think the only safe solution is using a chroot after all, but maybe I'm missing something here.

Similar Messages

  • How can you redo initial system setup macbook pro

    How can you redo initial system setup macbook pro?

    Like when Setup Assistant fires up and lets you migrate? In general, that would imply having to do a complete reinstall. And I've always been under the impression that when you do that, the reinstall software does not contain all the extra goodies that come with a new from-factory install (such as iLife).
    But as Prof. Kappy wants to know, the specifics are very version dependent.

  • How can you change your line access selection?  I have found where you can change your plan selection, but can you change the line access fee or is that a set amount?

    How can you change your line access selection?  I have found where you can change your plan selection, but can you change the line access fee or is that a set amount?

        DIVAB71,
    Great question. The line access fees for the account are a set amount and can not be changed unless you are going from a basic to a smartphone or vice versa. If you are wondering about adding the month to month discount if you are out of contract Ann154 has provided great information on how to access and add the feature.
    LindseyT_VZW
    Follow us on Twitter @VZWSupport

  • HT5105 How can you do picture in picture when you are working with a Multicam clip?

    How can you do picture in picture when you are working with a Multicam clip?

    Im doing a drumming music video and with the multi cam clip all the angles are nicely sync'd top the audio.
    Problem is if i want to have 3 angles on top of the main shot, im gonna have to re-sync them all to get them to line up manually. If i could use the multi cam clip they will already be aligned
    Thanks for trying to help appreciate, hoping someone has some multiclip knowledge and will be able to tell me if yay or nay.

  • How can I not allow wireless access when extending a network?

    I have two Airport Extremes, one extends the network of the other. How can I not allow wireless access on the remote Extreme when extending a network? I could do it with Airport Utility 5.6, but not with version 6 on Mavericks.

    Correct. Use another Mac or even a PC running Airport Utility 5.x.  Once you have the extending Extreme configured the way you want, Mavericks will not change the setting on the extending Extreme.

  • How can you fix your ipod touch when apps are closing on you, how can you fix your ipod touch when apps are closing on you

    How can you fix your ipod when apps keep crashing on you while your in that app?

    See:
    iOS: Troubleshooting applications purchased from the App Store
    Contact the developer/go to their support site if only one app.
    Restore from backup. See:
    iOS: How to back up              
    Restore to factory settings/new iPod

  • HT4623 How can u set up your iphone when all the files are deleted?

    How can I set up my iphone if all the files are deleted?

    What files are deleted?
    Please explain

  • How can you get custom sounds for when you sign into iChat?

    When you sign into my friend's iChat account on her computer, a computer voice says "Sarah is awesome!", and she obviously custom made that, and I was wondering how you can make custom sounds like that when you sign in.
    Thank you so much, I appreciate it!

    It can be done two ways.
    1) as the other poster describes in making an Alert Sound and placing it in Users/(your account)/Library/Sounds and then selecting it in iChat > Preferences > Alerts fro the action you want.
    2) In Tiger/iChat 3 only
    Go to the iChat Alert Preferences details above and there is an option to have iChat Speak a text phrase which you can type in the Phrase. (this is not there in iChat 4)
    8:14 PM Saturday; April 19, 2008

  • How can you reset your admin password when you can't remember it?

    Can you please tell me how I can reset my admin password when I can't remember it?

    Boot to the Recovery HD:
    Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    When the menubar appears select Terminal from the Utilities menu. Enter resetpassword at the prompt and press RETURN. Follow instructions in the dialog window that will appear.

  • How can you configure such system

    hi all ,
    some Supply Chain , has 1 server oralce 8 , 50 Distributors having Win98 running Personal Orale , each Distributor have many sales persons visiting retails and at the end of the day they manually enter their invoices in the Win98 Personal Oracle ,
    Personal Oralce replicates with the server every 24 hour using dial up connection ,
    they wanted to accelerate system by using Pocket PC 2002 with the sales persons ,
    how can we use oralce lite and Mobile Server in such a configuration ?
    N.B. they are not willing to change win98 machines
    regards

    1.u can see availabilty any time in ENVIRONMENT---> Availability
    2.In case of shortages system wil give a pop up for this the followoing setting has to be done:
    in SPRO>SALES AND DISTRIBUTION->BASIC FUNCTIONS> AVAILABILITY CHECK AND TOR-> AVAILABILITY CHECK->AVAILABILITY CHECK WITH ATP LOGIC OR AGAINST PLANNING-> DEFINE DEFAULT SETTINGS
    Here for ur sales area in rule put blank which wil give dialog box in case of shortages
    anil

  • How can I indicate the Excel version when downloading the file?

    Hi masters!
    how can i indicate witch version of excel file format (95 or 97) will be used when downloading?
    i'm using CL_WD_RUNTIME_SERVICES=>attach_file_to_response method now.
    Regards!
    Lucas

    Multipart request is not handled as www request.
    UploadBean might help you :
    http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html

  • How can i put a system.out.println into txt file

    i want to generate a txt file instead of system.out.println. for the output How can i do that and what code can i use for that??
    Edited by: crystalarun on Oct 14, 2007 11:40 AM

    suppose u ant output in "Output.txt"
    then code can be
    PrintStream out = new PrintStream(new FileOutputStream("Output.txt"));
    System.setOut(out)

  • How can you repair a MacBook air when it won't start properly?

    My MacBook Air is just over 3 years old and thus out of warranty.
    It gives a message that says the Preference Pane cannot be opened. Mostly the screen is black but sometimes (oddly) Adobe Bridge has a window ... but I cannot move to any other application.
    1) is Genius Bar only available if your product is under warranty?
    2) is there no way to check it? No recovery shows up when I option-restart.
    Advice would be appreciated. the closest Apple store is an hour away.
    Diane T

    Backup your files. If you have a 2010 model that came with a set of two software discs then do the following:
    Clean Install of Snow Leopard
    Be sure to make a backup first because the following procedure will erase
    the drive and everything on it.
         1. Boot the computer using the Snow Leopard Installer Disc or the Disc 1 that came
             with your computer.  Insert the disc into the optical drive and restart the computer.
             After the chime press and hold down the  "C" key.  Release the key when you see
             a small spinning gear appear below the dark gray Apple logo.
         2. After the installer loads select your language and click on the Continue
             button. When the menu bar appears select Disk Utility from the Utilities menu.
             After DU loads select the hard drive entry from the left side list (mfgr.'s ID and drive
             size.)  Click on the Partition tab in the DU main window.  Set the number of
             partitions to one (1) from the Partitions drop down menu, click on Options button
             and select GUID, click on OK, then set the format type to MacOS Extended
             (Journaled, if supported), then click on the Apply button.
         3. When the formatting has completed quit DU and return to the installer.  Proceed
             with the OS X installation and follow the directions included with the installer.
         4. When the installation has completed your computer will Restart into the Setup
             Assistant. Be sure you configure your initial admin account with the exact same
             username and password that you used on your old drive. After you finish Setup
             Assistant will complete the installation after which you will be running a fresh
             install of OS X.  You can now begin the update process by opening Software
             Update and installing all recommended updates to bring your installation current.
    Download and install Mac OS X 10.6.8 Update Combo v1.1. If you wish to upgrade to a later version of OS X, then do so on the App Store.
    If you have the 2011 model then do this:
    Install or Reinstall Yosemite, Mavericks, Mountain Lion, or Lion from Scratch
    Be sure you backup your files to an external drive or second internal drive because the following procedure will remove everything from the hard drive.
    How to Clean Install OS X Yosemite
    OS X Mavericks- Erase and reinstall OS X
    OS X Mountain Lion- Erase and reinstall OS X
    OS X Lion- Erase and reinstall Mac OS X
    Note: You will need an active Internet connection. I suggest using Ethernet if possible
                because it is three times faster than wireless.

  • How can you enter a line-break when using a Bluetooth Keyboard or onscreen Keyboard?

    In Pages & Keynote the only way to force a line break I have found is to put your finger at the end of a line until the select/insert option appears and then selecting insert, then select line break.
    This is frustratingly slow when typing a presentation or document so I bought a Logitech Ultrathin Bluetooth keyboard assuming that would have the Shift+Enter shortcut to make a line break. It doesn't, nor can I find any key combination that does, it's always a new paragraph, or nothing happens.
    I have an Ipad3,  IOS 6.1.3. I've spoken to Logitech support - they said talk to Apple iOS support, I spoke with a chap at IOS support who didn't know what a line break was, didn't know shift+enter on a PC made a line break so didn't understand my question and ended the call.
    Anyone know how to create the shortcut as an alternative to the onscreen slow way?

    Yes
    http://support.apple.com/kb/HT5633
    You can also download the remote app if you have an IOS device

  • How can you find photos taken today when connecting to pc

    You screwed up the software for any one using the Iphone as their camera, I used to use it constantly, but now I can not because of the way the new software recategorized my photos. The sub file folder names are totally useless to any one downloading to windows computers. Now I am forced to use another device an actual separate camera because of your screwing with the software handling of the photos. After all of your commercials about how people were using their Iphones as their primary camera, now you have made it useless to anyone using a PC to download their pictures!!!!!
    2
    Even after transferring all of my photos to my computer and deleting off of Iphone, as soon as I take additional photos and it creates another photo folder under the DCIM that has meaningless combination of letters and numbers but it still has the same date of 01/06/2014. This is stupid to say the least. When you create a new folder it should have the date created or modified not some obscure date that is meaningless. And if it creates a new folder every day with the same meaningless info (name and date)then it renders the Iphone useless as a camera!!!!!!!!!!!!!!!

    While not elegant you can use this method to find the latest photos relatively quickly.
    1. Open DCIM folder on the iPhone with Windows Explorer.
    2.. In the search bar type in an * (asterisk).
    3. This should display all of your photos including the date they were taken from all folders.
    4. Sort photos by date to locate the date range you need.
    5. Right click on any photo in the date range and then click on "open file location"
    This should open the folder with all the files in that date range. If the photos have been split over 2 folders then repeat the operation for the first and then the last in that date range. Also note that for some reason you cannot drag and drop nor copy and paste from the search results. You need to open the containing folder.
    Hope that helps until Apple fix the problem!!!

Maybe you are looking for

  • X86 printer driver for 64 bit Windows 7

    I have Windows 7 (64bit) on my computer.  I want to install an x86 driver for my HP Photosmart C6280 printer so my XP laptop can print to this printer through my home network.  I started by clicking on Devices and Printer, clicked on the Photosmart p

  • Objects (lines) and text boxes are not able to be made bigger or smaller

    first of all: For no reason at all, all of my text boxes are now set up as threaded text.  I dont know how that turned on.  When i go to "type" and try to select "threaded text" it wont allow me to select it - it is not highlighted.  So I have no clu

  • IPad 3 totally no sound.

    iPad 3 totally no sound and shows "sound effect" when adjusting volume. Tried restore many times but still can't solved. Also checked under setting that the change with button to "off". When change with button to "off" I try to adjust the volume, I c

  • I can not download movies get error 39 all the time

    i can not download movie keep getting error 39

  • Buffalo LS NAS Drive, Time Machine, Thinning

    I suspect part of this may have to go to the Buffalo forums. I have four shares on this, 2 with sparsebundles, each for a different Mac, and then a share each for iTunes and 'other' media. First question regards the sparsebundle's type (I guess). Not