]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/winbind.c
Fix include paths for plugins to use the public API of pppd
[ppp.git] / pppd / plugins / winbind.c
index 67c72f65ef3f0533e5a648bb8dda7647401f44ce..71c0d038fbaa4e852ddfd90a3c7d0fae72e5c54f 100644 (file)
 *
 ***********************************************************************/
 
-#include "pppd.h"
-#include "chap-new.h"
-#include "chap_ms.h"
-#include "fsm.h"
-#include "ipcp.h"
-#include "mppe.h"
 #include <syslog.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <ctype.h>
 
+#include <pppd/pppd.h>
+#include <pppd/chap-new.h>
+#include <pppd/chap_ms.h>
+#include <pppd/fsm.h>
+#include <pppd/ipcp.h>
+#include <pppd/mppe.h>
+
 #define BUF_LEN 1024
 
 #define NOT_AUTHENTICATED 0
@@ -100,7 +101,7 @@ static int winbind_chap_verify(char *user, char *ourname, int id,
                               char *message, int message_space);
 static int winbind_allowed_address(u_int32_t addr); 
 
-char pppd_version[] = VERSION;
+char pppd_version[] = PPPD_VERSION;
 
 /**********************************************************************
 * %FUNCTION: plugin_init
@@ -163,7 +164,7 @@ plugin_init(void)
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
-size_t strhex_to_str(char *p, size_t len, const char *strhex)
+size_t strhex_to_str(unsigned char *p, size_t len, const char *strhex)
 {
        size_t i;
        size_t num_chars = 0;
@@ -295,15 +296,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");
        }
@@ -518,7 +524,7 @@ winbind_chap_verify(char *user, char *ourname, int id,
        char *domain;
        char *username;
        char *p;
-       char saresponse[MS_AUTH_RESPONSE_LENGTH+1];
+       unsigned char saresponse[MS_AUTH_RESPONSE_LENGTH+1];
 
        /* The first byte of each of these strings contains their length */
        challenge_len = *challenge++;
@@ -560,14 +566,14 @@ winbind_chap_verify(char *user, char *ourname, int id,
                        nt_response = &response[MS_CHAP_NTRESP];
                        nt_response_size = MS_CHAP_NTRESP_LEN;
                } else {
-#ifdef MSLANMAN
+#ifdef PPP_WITH_MSLANMAN
                        lm_response = &response[MS_CHAP_LANMANRESP];
                        lm_response_size = MS_CHAP_LANMANRESP_LEN;
 #else
                        /* Should really propagate this into the error packet. */
                        notice("Peer request for LANMAN auth not supported");
                        return NOT_AUTHENTICATED;
-#endif /* MSLANMAN */
+#endif /* PPP_WITH_MSLANMAN */
                }
                
                /* ship off to winbind, and check */
@@ -581,7 +587,9 @@ winbind_chap_verify(char *user, char *ourname, int id,
                                  nt_response, nt_response_size,
                                  session_key,
                                  &error_string) == AUTHENTICATED) {
+#ifdef PPP_WITH_MPPE
                        mppe_set_chapv1(challenge, session_key);
+#endif
                        slprintf(message, message_space, "Access granted");
                        return AUTHENTICATED;
                        
@@ -626,8 +634,10 @@ winbind_chap_verify(char *user, char *ourname, int id,
                                &response[MS_CHAP2_NTRESP],
                                &response[MS_CHAP2_PEER_CHALLENGE],
                                challenge, user, saresponse);
+#ifdef PPP_WITH_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 {