|File Search||Catalog||Content Search|
mountpy - script for quick mounting of removable devices… more info»
written by Radovan Garabík e-mail: firstname.lastname@example.org mountpy is a python script for quick automatic mounting and umounting of external filesystems, especially suited for USB removable devices. mountpy is developped on linux, and is meant for modern linux systems. However, there is not much code linux-specific, so in theory it could work on any POSIX system with similar semantics of setuid(2), you just have to modify mount options. Motivation: I successfully converted several computer illiterate users to linux. While they are perfectly content and willing to learn to write a command before accessing an external filesystem, and an another command before removing the device, removable USB mass storage devices bring a lot of variety - some of them have partition table, some of them have not, they appear as different sd? devices, keeping /etc/fstab updated is difficult, and users have problems finding out the correct device (oce it is /dev/sda, the other time, with the same USB key, /dev/sdb...). This script tries to mount everything it can, probing all configured devices with all possible filesystems, and creating mountpoints as needed. Instalation: make && make install edit /etc/mountpy.conf to suit your needs Usage: There are 3 ways how to make mountpy run comfortably with root privileges: 1) install sudo, add this line to /etc/sudoers: joesmith ALL = NOPASSWD: /usr/bin/mountpy, usr/bin/umountpy to allow user joesmith use mountpy. It you want to allow all the users use mountpy, change the line into: ALL ALL = NOPASSWD: /usr/bin/mountpy, usr/bin/umountpy and then run "sudo mountpy" and "sudo umountpy" 2) install super, add these lines to /etc/super.tab: mountpy /usr/bin/mountpy.py joesmith umountpy /usr/bin/umountpy joesmith to allow user joesmith to run mountpy, or: mountpy /usr/bin/mountpy.py .* umountpy /usr/bin/umountpy .* to give access to all the users, and run "super mountpy" or "super umountpy" 3) make the C wrapper script setuid root log in as root and type: chmod u+s /usr/bin/mountpy Be aware that giving all the users rights to execute mountpy can be a security risk, if an exploitable bug is found in mountpy. This is especially true in the 3rd case. Therefore, it is recommended to allow only selected users to run mountpy, and use super or sudo if possible. use: $ mountpy to mount all the devices. Short summary will be printed. By default, you can find mounted filesystems under /media use: $ mountpy -u or $ umountpy to umount everything it can. Short summary will be printed, with warning if some device could not have been umounted $ mountpy device tries to mount only one device, e.g.: $ mountpy sda $ mountpy sda fd0 cdrom use -v to verbosely print what is going on, -vv to get even more information. Security: Do not install setuid mountpy on servers with multiuser access! It has no use in such an envirnment, anyway. While there is nothing directly exploitable, it is easy to trick python into executing something other It is perfectly suited for a workstation or a notebook, if a user already knows the root password, or in similar circumstances. Using sudo or super is safer, because you can select users who are allowed to run mountpy, but eventual bug in mountpy or python could allow them to gain unauthorized root access anyway. Special care has beed taken to avoid accidentally removing directories during umount, so the script should be safe. Of course, bugs are always possible. Using broken hardware (bad floppy, cdrom, USB key) can hang the program, or even crash the kernel, as with ordinary mount.