summaryrefslogtreecommitdiff
blob: d1fcca649d5ef72e436aa956fa4b6943b101c644 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Don't abort if we can't access /etc/fstab

http://bugs.gentoo.org/91977

--- eject.c
+++ eject.c
@@ -656,8 +656,13 @@
 
 	fp = fopen("/etc/fstab", "r");
 	if (fp == NULL) {
-		fprintf(stderr, _("%s: unable to open /etc/fstab: %s\n"), programName, strerror(errno));
-		exit(1);
+		/*
+		 * /etc/fstab may be unreadable in some situations due to passwords in the
+		 * file.
+		 */
+		if (v_option)
+			printf( _("%s: unable to open /etc/fstab: %s\n"), programName, strerror(errno));
+		return -1;
 	}
 
 	while (fgets(line, sizeof(line), fp) != 0) {
@@ -890,7 +895,8 @@
 	/* if not currently mounted, see if it is a possible mount point */
 	if (!mounted) {
 		mountable = MountableDevice(fullName, &mountName, &deviceName);
-		if (v_option) {
+		/* if return value -1 then fstab could not be read */
+		if (v_option && (mountable >= 0)) {
 			if (mountable)
 				printf(_("%s: `%s' can be mounted at `%s'\n"), programName, deviceName, mountName);
 			else