[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gap-dev-discuss] GWorkspace umounting CD-Roms on OpenBSD
From: |
Sebastian Reitenbach |
Subject: |
[Gap-dev-discuss] GWorkspace umounting CD-Roms on OpenBSD |
Date: |
Mon, 16 Jul 2012 18:56:21 +0200 |
User-agent: |
SOGoMail 1.3.16 |
Hi,
at least with OpenBSD and allowing user mounts (sysctl kern.usermount=1), then,
at least when mounting a CD-Rom, the mount point directory changes ownership to
root:wheel. For USB sticks, the ownership of the mountpoint stays the same.
manually on the console, I can umount the CD-Rom device.
But trying to drag 'n drop the cd-rom device into the trash, I get the error,
that I must be root to do that.
I changed the GWorkspace code, so that it just tries to umount the partition,
and then, in case it fails, throws the error message.
Also I made the error message a bit more generic (there is usually no "root"
user under Windows ;).
What do you think about that?
Sebastian
$OpenBSD$
allow unmounting of CD-Rom devices
--- GWorkspace/Desktop/Dock/DockIcon.m.orig Mon Jul 16 18:24:57 2012
+++ GWorkspace/Desktop/Dock/DockIcon.m Mon Jul 16 18:42:14 2012
@@ -566,14 +566,7 @@ x += 6; \
NSMutableArray *umountPaths = [NSMutableArray array];
NSMutableDictionary *opinfo = [NSMutableDictionary dictionary];
NSString *username = NSUserName();
- BOOL iamRoot;
- #ifdef __WIN32__
- iamRoot = YES;
- #else
- iamRoot = (geteuid() == 0);
- #endif
-
for (i = 0; i < [paths count]; i++) {
NSString *srcpath = [paths objectAtIndex: i];
@@ -587,15 +580,12 @@ x += 6; \
for (i = 0; i < [umountPaths count]; i++) {
NSString *umpath = [umountPaths objectAtIndex: i];
NSDictionary *attrs = [fm fileAttributesAtPath: umpath
traverseLink: NO];
- NSString *usr = [attrs objectForKey: NSFileOwnerAccountName];
- BOOL isMyFile = ([username isEqual: usr]);
- if (iamRoot || isMyFile) {
- [ws unmountAndEjectDeviceAtPath: umpath];
- } else {
- NSString *err = NSLocalizedString(@"Error", @"");
- NSString *msg = NSLocalizedString(@"You must be root to
umount\n", @"");
- NSString *buttstr = NSLocalizedString(@"Continue", @"");
+ if (![ws unmountAndEjectDeviceAtPath: umpath])
+ {
+ NSString *err = NSLocalizedString(@"Error", @"");
+ NSString *msg = NSLocalizedString(@"You are not allowed to
umount\n", @"");
+ NSString *buttstr = NSLocalizedString(@"Continue", @"");
NSRunAlertPanel(err, [NSString stringWithFormat: @"%@
\"address@hidden"!\n", msg, umpath], buttstr, nil, nil);
}
}
- [Gap-dev-discuss] GWorkspace umounting CD-Roms on OpenBSD,
Sebastian Reitenbach <=