summaryrefslogtreecommitdiff
path: root/mgetty/mgetty-1.1.30/40-locks.c_bug153394
blob: 0de2fb6b0fab4bac597584f58ab7564fad839131 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--- mgetty-1.1.28.old/locks.c	2001-01-06 12:46:34.000000000 -0500
+++ mgetty-1.1.28/locks.c	2002-08-03 16:25:02.000000000 -0400
@@ -394,9 +394,42 @@
 
 #else	/* not SVR4 */ 
 
+static char * unslash_name _P1 ( (device),
+				 char *device )
+{
+    char *lock_device, *ldev_begin, *ldevice_orig;
+
+    ldevice_orig = malloc( strlen (device) + 1 );
+    sprintf( ldevice_orig, "%s", device );
+
+    lock_device = strchr( ldevice_orig, '/' );
+    while (lock_device)
+      {
+	*lock_device = '_';
+	lock_device = strchr( lock_device, '/' );
+      }
+
+    if ( *ldevice_orig == '_' )
+      {
+	lock_device = strchr( ldevice_orig + 1, '_' );
+	if (! lock_device)
+	  lock_device = ldevice_orig;
+	lock_device++;
+      }
+    else
+      lock_device = ldevice_orig;
+
+    ldev_begin = malloc( strlen( lock_device ) + 1 );
+    sprintf( ldev_begin, "%s", lock_device );
+    free( ldevice_orig );
+
+    return ldev_begin;
+}
+
 static char * get_lock_name _P2( (lock_name, device),
 			  char * lock_name, char * device )
 {
+    char *lock;
 #ifdef LOCKS_LOWERCASE
     /* sco locking convention -> change all device names to lowercase */
 
@@ -425,10 +458,10 @@
 #endif	/* LOCKS_LOWERCASE */
 
     /* throw out all directory prefixes */
-    if ( strchr( device, '/' ) != NULL )
-        device = strrchr( device, '/' ) +1;
-    
-    sprintf( lock_name, LOCK, device);
+
+    lock = unslash_name ( device );
+    sprintf( lock_name, LOCK, lock );
+    free ( lock );
 
     return lock_name;
 }