summaryrefslogtreecommitdiff
path: root/debian/patches/10norootpassword.patch
blob: fa24c8f99b8a86728eeb05be14fff2d9c5a4cd80 (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
61
62
Author: Martin Pitt <martin.pitt@ubuntu.com>
Description: When locking a root-owned screen, check that root has a
password set. If not, ask for an unlocking key.
See https://bugs.launchpad.net/bugs/6760
Index: screen/attacher.c
===================================================================
--- screen.orig/attacher.c	2011-10-08 19:54:22.000000000 +0200
+++ screen/attacher.c	2011-10-08 19:58:12.000000000 +0200
@@ -847,11 +847,15 @@
 #ifdef USE_PAM
   pam_handle_t *pamh = 0;
   int pam_error;
-#else
-  char *pass, mypass[16 + 1], salt[3];
 #endif
+  char *pass, mypass[16 + 1], salt[3];
+  int using_pam = 1;
 
-#ifndef USE_PAM
+#ifdef USE_PAM
+  if (!ppp->pw_uid)
+    {
+#endif
+  using_pam = 0;
   pass = ppp->pw_passwd;
   if (pass == 0 || *pass == 0)
     {
@@ -884,6 +888,8 @@
       pass = crypt(mypass, salt);
       pass = ppp->pw_passwd = SaveStr(pass);
     }
+#ifdef USE_PAM
+    }
 #endif
 
   debug("screen_builtin_lck looking in gcos field\n");
@@ -913,6 +919,8 @@
           AttacherFinit(SIGARG);
           /* NOTREACHED */
         }
+      if (using_pam)
+        {
 #ifdef USE_PAM
       PAM_conversation.appdata_ptr = cp1;
       pam_error = pam_start("screen", ppp->pw_name, &PAM_conversation, &pamh);
@@ -923,10 +931,13 @@
       PAM_conversation.appdata_ptr = 0;
       if (pam_error == PAM_SUCCESS)
 	break;
-#else
-      if (!strncmp(crypt(cp1, pass), pass, strlen(pass)))
-	break;
 #endif
+        }
+      else
+	{
+          if (!strncmp(crypt(cp1, pass), pass, strlen(pass)))
+	    break;
+	}
       debug("screen_builtin_lck: NO!!!!!\n");
       bzero(cp1, strlen(cp1));
     }