Announcement

Collapse
No announcement yet.

Disable /Enable USB Storage in Kubuntu 12.04 LTS.

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Disable /Enable USB Storage in Kubuntu 12.04 LTS.

    Dear Friends

    I am working on a script which enables and Disables the USB ports for mass storage devices. when it is need to disable I make entry /etc/modprobe.d/blacklist.conf blaclist usb_storage and when it is required to enable back i comment is this line by my script. And also i rename the module usb-storage.ko as per enable/disable.

    This method is working fine for me. and my scripts results the desire (please avoid the typing mistakes).

    Now I want ...?

    Problem No. 1
    suppose there are five standard users in my system (like abc , def, ghi, jkl, mno etc.) and as a administrator I have to enable the USB storage on for one particular user for example from five users only user abc should be able to use the USB storage devices in system rest all user should not. How can I do this ? does any third party tool or software is required for this job if yes the what ? if not then how can I do this ?

    Problem No 2
    when my user abc usages the USB stick in system, Script has to capture the hash and file name of all the data which has been copied/moved in to the system or copied/moved from the system to USB devices. and this script should be activated only when a USB device is plugged in. by any method.

    Please help me as soon as possible ........... I will be glade ful to you

    #2
    Sounds like complicated security.

    No. 1: If only one user gets USB access, then the blacklisting should be default. Then run a script to un-blacklist USB on log in of user abc and re-blacklist when abc logs out. One place to do this is Xstartup and Xreset in /etc/X11/

    I don't remember the exact syntax (I'll post again later tonight unless someone else saves me)

    If $USER="abc"
    then DO_SOME_SCRIPT

    something like that should work.

    Please Read Me

    Comment


      #3
      I got the IDEA thanks

      But in /etc/X11 how can i define that my script should run only my desired user "abc" loges in and if at the same time another user also loges in and starts new sessions then the same time script should exit to block usb. Please describe in details

      My script is running with root priviledge now at startup in /etc/rc.local and if I place the same script in X11 then I have to enable sudo for then which I don't want

      please help

      Comment


        #4
        Well, I can't make you try it. If you don't want to - don't.

        rc.local runs at system startup, not just when a user logs in so it won't do what you ask. /etc/X11/Xsession is parsed as root when any user logs in.

        If my memory serves:

        /etc/X11/Xreset
        script to run as root after session exits

        /etc/X11/Xsession
        script to run as user after login of user

        /etc/X11/Xsetup
        script to run as root before the login dialog appears
        The format would be:

        Code:
        if [ $USER = "abc" ]; then
             ./some_dir/some_script 
        fi
        Put the above with the script name that turns USB on in Xsession and the script that turns it back off in Xreset. You will have to give the abc user a NOPASS in sudoers for this particular script. Edit sudoers with visudo command and add

        Code:
        abc ALL=NOPASSWD: /some_dir/some_script
        Last edited by oshunluvr; Feb 25, 2014, 12:50 AM.

        Please Read Me

        Comment

        Working...
        X