pam: add a header; remove undefined/unused functions 35/13935/1
authorPatrick McCarty <patrick.mccarty@linux.intel.com>
Tue, 17 Dec 2013 01:22:44 +0000 (17:22 -0800)
committerPatrick McCarty <patrick.mccarty@linux.intel.com>
Wed, 18 Dec 2013 17:10:45 +0000 (09:10 -0800)
Change-Id: I3932ea31d4b635b77caf3feb1a23da9ce0b1f33b
Signed-off-by: Patrick McCarty <patrick.mccarty@linux.intel.com>
src/pam.c
src/pam.h [new file with mode: 0644]

index 8a1b04e..b244ac6 100644 (file)
--- a/src/pam.c
+++ b/src/pam.c
@@ -22,7 +22,7 @@
 
 #include <security/pam_appl.h>
 
-#include "user-session.h"
+#include "pam.h"
 
 static pam_handle_t *ph;
 static struct pam_conv pc;
@@ -40,9 +40,7 @@ pam_conversation_fn(int msg_count,
        int i;
        (void)user_data;
 
-       d_in();
-
-       lprintf("pam conversation with %d messages", msg_count);
+       printf("pam conversation with %d messages", msg_count);
        if (responses)
                *responses = NULL;
 
@@ -51,7 +49,7 @@ pam_conversation_fn(int msg_count,
 
        /* otherwise find any helpful data we can to print, and bail */
        if (!responses || !messages) {
-               lprintf("pam conversation with no message, or response");
+               printf("pam conversation with no message, or response");
                return PAM_CONV_ERR;
        }
        *responses = calloc (msg_count, sizeof (struct pam_response));
@@ -59,17 +57,16 @@ pam_conversation_fn(int msg_count,
                const struct pam_message *msg = messages[i];
 
                if (msg->msg_style == PAM_TEXT_INFO)
-                       lprintf("pam chats to us: '%s'", msg->msg);
+                       printf("pam chats to us: '%s'", msg->msg);
                else if (msg->msg_style == PAM_ERROR_MSG)
-                       lprintf("Error: pam error msg '%s'", msg->msg);
+                       printf("Error: pam error msg '%s'", msg->msg);
                else
-                       lprintf("pam message %d style %d: '%s'",
+                       printf("pam message %d style %d: '%s'",
                                 i, msg->msg_style, msg->msg);
                (*responses)[i].resp = NULL;
                (*responses)[i].resp_retcode = PAM_SUCCESS;
        }
 
-       d_out();
        return PAM_SUCCESS;
 }
 
@@ -84,13 +81,8 @@ pam_conversation_fn(int msg_count,
  */
 void setup_pam_session(void)
 {
-       char x[256];
        int err;
 
-       d_in();
-
-       snprintf(x, 256, "tty%d", tty);
-
        pc.conv = pam_conversation_fn;
        pc.appdata_ptr = NULL;
 
@@ -98,33 +90,29 @@ void setup_pam_session(void)
 
        err = pam_set_item(ph, PAM_TTY, &x);
        if (err != PAM_SUCCESS) {
-               lprintf("pam_set_item PAM_TTY returned %d: %s\n", err, pam_strerror(ph, err));
+               printf("pam_set_item PAM_TTY returned %d: %s\n", err, pam_strerror(ph, err));
                exit(EXIT_FAILURE);
        }
 
        err = pam_set_item(ph, PAM_XDISPLAY, &displayname);
        if (err != PAM_SUCCESS) {
-               lprintf("pam_set_item PAM_DISPLAY returned %d: %s\n", err, pam_strerror(ph, err));
+               printf("pam_set_item PAM_DISPLAY returned %d: %s\n", err, pam_strerror(ph, err));
                exit(EXIT_FAILURE);
        }
 
        err = pam_open_session(ph, 0);
        if (err != PAM_SUCCESS) {
-               lprintf("pam_open_session returned %d: %s\n", err, pam_strerror(ph, err));
+               printf("pam_open_session returned %d: %s\n", err, pam_strerror(ph, err));
                exit(EXIT_FAILURE);
        }
-       d_out();
 }
 
 void close_pam_session(void)
 {
        int err;
 
-       d_in();
-
        err = pam_close_session(ph, 0);
        if (err)
-               lprintf("pam_close_session returned %d: %s\n", err, pam_strerror(ph, err));
+               printf("pam_close_session returned %d: %s\n", err, pam_strerror(ph, err));
        pam_end(ph, err);
-       d_out();
 }
diff --git a/src/pam.h b/src/pam.h
new file mode 100644 (file)
index 0000000..8f9f751
--- /dev/null
+++ b/src/pam.h
@@ -0,0 +1,18 @@
+/*
+ * This file is part of user-session-units
+ *
+ * (C) Copyright 2013 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+#ifndef __PAM_H__
+#define __PAM_H__
+
+void setup_pam_session(void);
+void close_pam_session(void);
+
+#endif /* __PAM_H_ */