Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Large update to pc-mounttray:
Browse files Browse the repository at this point in the history
1) Convert over to running with user permissions
2) All devices will now be mounted in the ~/Media directory (it gets created as necessary when the application starts up)
3) If a device gets a permissions error when mounting, it will immediately fall back to asking the user to mount the device as root with pc-su.
4) Once a device is flagged as requiring root permissions, it will update the icon with a little yellow shield in the corner for easy identification.

Currently tested with FAT, NTFS, UFS, and ISO/CD9660 filesystems.
Some new quirks:
1) The first FAT device to get mounted after system bootup will require root permissions, while subsequent FAT devices/mounts will only need user perms. This is because of a FreeBSD bug in mount_ntfs when the localization flag is used (-L=<mylocale>)
2) NTFS filesystems appear to always need root permissions to mount (have not explicitly flagged that filesystem for root yet until after additional testing)
  • Loading branch information
Ken Moore committed Mar 18, 2014
1 parent 40cafc7 commit 2532cb9
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 136 deletions.
Binary file added src-qt4/pc-mounttray/icons/root-overlay.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 18 additions & 5 deletions src-qt4/pc-mounttray/main.cpp
Expand Up @@ -17,25 +17,38 @@
bool DEBUG_MODE;
QString DEVICEDIR;
QString MOUNTDIR;
//QString ROOTMOUNTDIR;
//QString USERNAME;

int main(int argc, char ** argv)
{
//Check for root permissions
QString id = QProcessEnvironment::systemEnvironment().toStringList().filter("LOGNAME=").join(" ").remove("LOGNAME=").simplified();
//qDebug() << id;
if( id != "root" ){
qDebug() << "pc-mounttray requires root permissions for device management!";
qDebug() << " - HINT: run 'sudo pc-mounttray' instead";
if( id == "root" ){
qDebug() << "pc-mounttray should not be started with root permissions";
exit(1);
}
}/*else{
USERNAME = id;
}*/
//Check for "-v" flag for debugging
QString flag = QString(argv[1]);
if( flag == "-v" || flag == "-debug" ){ DEBUG_MODE=TRUE; }
else{ DEBUG_MODE=FALSE; }

//Now start the application
DEVICEDIR = "/dev/";
MOUNTDIR = "/media/";
MOUNTDIR = QDir::homePath()+"/Media/";
//ROOTMOUNTDIR = "/media/";
if(!QFile::exists(MOUNTDIR)){
QDir dir(MOUNTDIR);
bool ok = dir.mkpath(dir.absolutePath());
if(!ok){
qDebug() << "Error: Could not create the user media directory:" << MOUNTDIR;
qDebug() << " - No way to mount devices: exiting....";
exit(1);
}
}
QtSingleApplication a(argc, argv);
if ( a.isRunning() )
return !(a.sendMessage("show"));
Expand Down

0 comments on commit 2532cb9

Please sign in to comment.