]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/winbind.c
Fixing CLang warnings w.r.t. GNU-style designator in structure declaration
[ppp.git] / pppd / plugins / winbind.c
index 4638f46530469fa29812c5b45c56c06263d27745..86b5198dd0d8b61624cabb1cfa68550cffde4bb6 100644 (file)
 *
 ***********************************************************************/
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "pppd.h"
 #include "chap-new.h"
 #include "chap_ms.h"
-#ifdef MPPE
-#include "md5.h"
-#endif
 #include "fsm.h"
 #include "ipcp.h"
+#include "mppe.h"
 #include <syslog.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -297,15 +299,20 @@ unsigned int run_ntlm_auth(const char *username,
        if (forkret == 0) {
                /* child process */
                uid_t uid;
+               gid_t gid;
 
                close(child_out[0]);
                close(child_in[1]);
 
                /* run winbind as the user that invoked pppd */
-               setgid(getgid());
+               gid = getgid();
+               if (setgid(gid) == -1 || getgid() != gid) {
+                       fatal("pppd/winbind: could not setgid to %d: %m", gid);
+               }
                uid = getuid();
-               if (setuid(uid) == -1 || getuid() != uid)
+               if (setuid(uid) == -1 || getuid() != uid) {
                        fatal("pppd/winbind: could not setuid to %d: %m", uid);
+               }
                execl("/bin/sh", "sh", "-c", ntlm_auth, NULL);  
                fatal("pppd/winbind: could not exec /bin/sh: %m");
        }
@@ -443,7 +450,7 @@ unsigned int run_ntlm_auth(const char *username,
                 return NOT_AUTHENTICATED;
         }
 
-       while ((wait(&status) == -1) && errno == EINTR)
+       while ((wait(&status) == -1) && errno == EINTR && !got_sigterm)
                 ;
 
        if ((authenticated == AUTHENTICATED) && nt_key && !got_user_session_key) {
@@ -583,7 +590,9 @@ winbind_chap_verify(char *user, char *ourname, int id,
                                  nt_response, nt_response_size,
                                  session_key,
                                  &error_string) == AUTHENTICATED) {
-                       mppe_set_keys(challenge, session_key);
+#ifdef MPPE
+                       mppe_set_chapv1(challenge, session_key);
+#endif
                        slprintf(message, message_space, "Access granted");
                        return AUTHENTICATED;
                        
@@ -628,8 +637,10 @@ winbind_chap_verify(char *user, char *ourname, int id,
                                &response[MS_CHAP2_NTRESP],
                                &response[MS_CHAP2_PEER_CHALLENGE],
                                challenge, user, saresponse);
-                       mppe_set_keys2(session_key, &response[MS_CHAP2_NTRESP],
+#ifdef MPPE
+                       mppe_set_chapv2(session_key, &response[MS_CHAP2_NTRESP],
                                       MS_CHAP2_AUTHENTICATOR);
+#endif
                        if (response[MS_CHAP2_FLAGS]) {
                                slprintf(message, message_space, "S=%s", saresponse);
                        } else {