patches/gnome-screensaver-01-pam-audit.diff
author jurikm
Sun, 12 Feb 2012 14:04:10 +0000
changeset 8245 383896da4129
parent 1882 17cc736d398e
permissions -rw-r--r--
SFEsauerbraten.spec: add IPS package name
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1882
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     1
--- gnome-screensaver-2.24.1-orig/configure.ac 2009-05-11 10:53:58.935363066 -0700
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     2
+++ gnome-screensaver-2.24.1/configure.ac 2009-05-11 10:54:39.210226052 -0700
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     3
@@ -584,6 +584,8 @@
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     4
       AC_CHECK_LIB(rt, sigtimedwait, [AUTH_LIBS="${AUTH_LIBS} -lrt"])
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     5
     fi
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     6
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     7
+    AC_CHECK_LIB(bsm, adt_start_session, [AUTH_LIBS="${AUTH_LIBS} -lbsm"])
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     8
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
     9
     AC_MSG_CHECKING(how to call pam_strerror)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    10
     AC_CACHE_VAL(ac_cv_pam_strerror_args,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    11
      [AC_TRY_COMPILE([#include <stdio.h>
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    12
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    13
--- gnome-screensaver-2.24.1/src/gs-auth-pam.c.orig	2008-04-29 19:30:08.000000000 -0700
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    14
+++ gnome-screensaver-2.24.1/src/gs-auth-pam.c	2009-05-15 11:37:22.805307934 -0700
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    15
@@ -99,6 +99,128 @@
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    16
 static GCond  *message_handled_condition;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    17
 static GMutex *message_handler_mutex;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    18
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    19
+#ifdef  sun
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    20
+#include <syslog.h>
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    21
+#include <bsm/adt.h>
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    22
+#include <bsm/adt_event.h>
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    23
+#include <deflt.h>
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    24
+static gboolean audit_flag_global = TRUE;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    25
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    26
+/*
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    27
+ * audit_lock - audit entry to screenlock
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    28
+ *
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    29
+ *      Entry   Process running with appropriate privilege to generate
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    30
+ *                      audit records and real uid of the user.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    31
+ *
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    32
+ *      Exit    ADT_screenlock audit record written.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    33
+ */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    34
+void
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    35
+audit_lock(void)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    36
+{
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    37
+        adt_session_data_t      *ah;  	/* audit session handle */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    38
+        adt_event_data_t        *event;	/* audit event handle */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    39
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    40
+      	/* Audit start of screen lock -- equivalent to logout ;-) */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    41
+        if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    42
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    43
+                syslog(LOG_AUTH | LOG_ALERT, "adt_start_session: %m");
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    44
+                return;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    45
+        }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    46
+        if ((event = adt_alloc_event(ah, ADT_screenlock)) == NULL) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    47
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    48
+                syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    49
+                    "adt_alloc_event(ADT_screenlock): %m");
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    50
+        } else {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    51
+                if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    52
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    53
+                        syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    54
+                            "adt_put_event(ADT_screenlock): %m");
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    55
+                }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    56
+                adt_free_event(event);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    57
+        }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    58
+        (void) adt_end_session(ah);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    59
+}
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    60
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    61
+/*
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    62
+ * audit_unlock - audit screen unlock
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    63
+ *
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    64
+ *      Entry   Process running with appropriate privilege to generate
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    65
+ *                      audit records and real uid of the user.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    66
+ *              pam_status = PAM error code; reason for failure.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    67
+ *
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    68
+ *      Exit    ADT_screenunlock audit record written.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    69
+ */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    70
+static void
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    71
+audit_unlock(int pam_status)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    72
+{
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    73
+        adt_session_data_t      *ah;  	/* audit session handle */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    74
+        adt_event_data_t        *event;/* audit event handle */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    75
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    76
+        if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    77
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    78
+                syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    79
+                    "adt_start_session(ADT_screenunlock): %m");
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    80
+                return;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    81
+        }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    82
+        if ((event = adt_alloc_event(ah, ADT_screenunlock)) == NULL) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    83
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    84
+                syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    85
+                    "adt_alloc_event(ADT_screenunlock): %m");
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    86
+        } else {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    87
+                if (adt_put_event(event,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    88
+                    pam_status == PAM_SUCCESS ? ADT_SUCCESS : ADT_FAILURE,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    89
+                    pam_status == PAM_SUCCESS ? ADT_SUCCESS : ADT_FAIL_PAM +
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    90
+                    pam_status) != 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    91
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    92
+                        syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    93
+                            "adt_put_event(ADT_screenunlock(%s): %m",
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    94
+                            pam_strerror(NULL, pam_status));
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    95
+                }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    96
+                adt_free_event(event);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    97
+        }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    98
+        (void) adt_end_session(ah);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    99
+}
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   100
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   101
+/*
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   102
+ * audit_passwd - audit password change
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   103
+ *      Entry   Process running with appropriate privilege to generate
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   104
+ *                      audit records and real uid of the user.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   105
+ *              pam_status = PAM error code; reason for failure.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   106
+ *
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   107
+ *      Exit    ADT_passwd audit record written.
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   108
+ */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   109
+static void
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   110
+audit_passwd(int pam_status)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   111
+{
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   112
+        adt_session_data_t      *ah;		/* audit session handle */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   113
+        adt_event_data_t        *event;	/* audit event handle */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   114
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   115
+        if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   116
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   117
+                syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   118
+                    "adt_start_session(ADT_passwd): %m");
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   119
+                return;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   120
+        }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   121
+        if ((event = adt_alloc_event(ah, ADT_passwd)) == NULL) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   122
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   123
+                syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   124
+                    "adt_alloc_event(ADT_passwd): %m");
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   125
+        } else {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   126
+                if (adt_put_event(event,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   127
+                    pam_status == PAM_SUCCESS ? ADT_SUCCESS : ADT_FAILURE,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   128
+                    pam_status == PAM_SUCCESS ? ADT_SUCCESS : ADT_FAIL_PAM +
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   129
+                    pam_status) != 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   130
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   131
+                        syslog(LOG_AUTH | LOG_ALERT,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   132
+                            "adt_put_event(ADT_passwd(%s): %m",
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   133
+                            pam_strerror(NULL, pam_status));
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   134
+                }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   135
+                adt_free_event(event);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   136
+        }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   137
+        (void) adt_end_session(ah);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   138
+}
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   139
+#endif /* sun */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   140
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   141
 GQuark
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   142
 gs_auth_error_quark (void)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   143
 {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   144
@@ -481,14 +603,34 @@
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   145
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   146
 static int
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   147
 gs_auth_thread_func (int auth_operation_fd)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   148
-{
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   149
-        static const int flags = 0;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   150
+{
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   151
+        int              flags = 0;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   152
         int              status;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   153
         int              status2;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   154
         struct timespec  timeout;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   155
         sigset_t         set;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   156
         const void      *p;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   157
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   158
+#ifdef sun
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   159
+        if (audit_flag_global) /* We want one audit lock log per lock */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   160
+            audit_lock();
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   161
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   162
+        /* Check /etc/default/login to see if we should add
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   163
+           PAM_DISALLOW_NULL_AUTHTOK to pam_flags */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   164
+        if (defopen("/etc/default/login") == 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   165
+            char *ptr;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   166
+            int tflags = defcntl(DC_GETFLAGS, 0);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   167
+            TURNOFF(tflags, DC_CASE);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   168
+            (void) defcntl(DC_SETFLAGS, tflags);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   169
+            if ((ptr = defread("PASSREQ=")) != NULL &&
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   170
+              strcasecmp("YES", ptr) == 0) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   171
+                flags |= PAM_DISALLOW_NULL_AUTHTOK;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   172
+            }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   173
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   174
+            (void) defopen((char *)NULL); /* close current file */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   175
+        }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   176
+#endif /* sun */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   177
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   178
         timeout.tv_sec = 0;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   179
         timeout.tv_nsec = 1;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   180
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   181
@@ -499,6 +641,12 @@
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   182
         sigtimedwait (&set, NULL, &timeout);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   183
         unblock_sigchld ();
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   184
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   185
+#ifdef sun
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   186
+        audit_unlock(status);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   187
+        if (status == PAM_SUCCESS) audit_flag_global = TRUE;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   188
+        else audit_flag_global = FALSE;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   189
+#endif /* sun */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   190
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   191
         if (gs_auth_get_verbose ()) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   192
                 g_message ("   pam_authenticate (...) ==> %d (%s)",
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   193
                            status,
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   194
@@ -528,11 +676,32 @@
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   195
                            PAM_STRERROR (pam_handle, status2));
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   196
         }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   197
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   198
+#ifdef sun
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   199
+        if (status2 != PAM_SUCCESS)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   200
+                audit_unlock(status2);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   201
+#endif /* sun */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   202
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   203
         /* FIXME: should we handle these? */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   204
         switch (status2) {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   205
         case PAM_SUCCESS:
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   206
                 break;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   207
         case PAM_NEW_AUTHTOK_REQD:
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   208
+#ifdef sun
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   209
+                {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   210
+                  int tst;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   211
+                  for (int i=0; i<3; i++) 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   212
+                  {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   213
+                    tst  = pam_chauthtok(pam_handle, PAM_CHANGE_EXPIRED_AUTHTOK);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   214
+                    if (tst == PAM_AUTHTOK_ERR ||
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   215
+                        tst == PAM_TRY_AGAIN ) 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   216
+                    {
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   217
+                      i = 0; /* Reset num tries we need to do to change expired passwd */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   218
+                    }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   219
+                    else break; /* get out of the loop */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   220
+                  } /* for */ 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   221
+                  audit_passwd(tst);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   222
+#endif /* sun */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   223
+                }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   224
                 break;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   225
         case PAM_AUTHINFO_UNAVAIL:
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   226
                 break;
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   227
@@ -560,6 +729,12 @@
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   228
                            PAM_STRERROR (pam_handle, status2));
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   229
         }
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   230
 
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   231
+#ifdef sun
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   232
+        if (status2 != PAM_SUCCESS)
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   233
+        /* Only in failure of pam_setcred() case we call audit. */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   234
+            audit_unlock(status2);
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   235
+#endif /* sun */
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   236
+
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   237
  done:
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   238
         /* we're done, close the fd and wake up the main
17cc736d398e 2009-05-19 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   239
          * loop