Browse code

put passwd handling in separate source file

Dario Rodriguez authored on 25/06/2014 17:09:44
Showing 4 changed files
... ...
@@ -10,10 +10,11 @@ clean:
10 10
 
11 11
 kakumei: kakumei.o loglib.o parselib.o sbuf.o \
12 12
 		socklib.o webkernel.o gen_res.o \
13
-		kakumei_session.o
13
+		kakumei_session.o kakumei_pass.o
14 14
 	$(CC) $(LDFLAGS) kakumei.o loglib.o parselib.o sbuf.o \
15 15
 		socklib.o webkernel.o gen_res.o \
16
-		kakumei_session.o -o kakumei
16
+		kakumei_session.o kakumei_pass.o \
17
+		-o kakumei
17 18
 
18 19
 kakumei.o: kakumei.c ../src/gen_res.c
19 20
 
... ...
@@ -20,6 +20,7 @@
20 20
 #include "webkernel.h"
21 21
 #include "kakumei.h"
22 22
 #include "kakumei_session.h"
23
+#include "kakumei_pass.h"
23 24
 
24 25
 static int signal_init(int signum, void (*fn)(int));
25 26
 static void sigint(int signum);
... ...
@@ -29,8 +30,6 @@ wk_action callback_http(wk *web, int connid, wk_uri *uri, void *userptr);
29 30
 wk_action http_login(wk *web, int connid, wk_uri *uri, void *userptr);
30 31
 wk_action http_newuser(wk *web, int connid, wk_uri *uri, void *userptr);
31 32
 
32
-int pass_check(char *user, char *passwd);
33
-
34 33
 int
35 34
 main(int argc, char *argv[])
36 35
 {
... ...
@@ -139,7 +138,8 @@ http_login(wk *web, int connid, wk_uri *uri, void *userptr)
139 138
                 wk_serve_buffer_as_file(web,connid,reply,strlen(reply),"text/plain");
140 139
                 return(wkact_finished);
141 140
         } else if(strchr(u,'/')==NULL && strchr(u,'.')==NULL &&
142
-          stat(userpath,&st)==0 && S_ISREG(st.st_mode) && pass_check(u,p)==0 &&
141
+          stat(userpath,&st)==0 && S_ISREG(st.st_mode) &&
142
+          pass_check(ka,u,p)==0 &&
143 143
           session_new(ka,u,session,sizeof(session))!=NULL) {
144 144
                 /* valid login */
145 145
                 snprintf(reply,sizeof(reply),"/posts.html?s=%s",session);
... ...
@@ -160,10 +160,3 @@ http_newuser(wk *web, int connid, wk_uri *uri, void *userptr)
160 160
 }
161 161
 
162 162
 
163
-int
164
-pass_check(char *user, char *passwd)
165
-{
166
-#warning TODO
167
-        return(-1);
168
-}
169
-
170 163
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+/*
2
+ * kakumei_pass.h
3
+ *
4
+ * Password handling for kakumei.
5
+ *
6
+ * Author: Dario Rodriguez dario@softhome.net
7
+ * This progran is licensed under the terms of the Affero GPL v1+
8
+ */
9
+
10
+#include "kakumei.h"
11
+
12
+int
13
+pass_new(kakumei *ka, char *user, char *passwd)
14
+{
15
+#warning TODO
16
+        return(-1);
17
+}
18
+
19
+int
20
+pass_check(kakumei *ka, char *user, char *passwd)
21
+{
22
+#warning TODO
23
+        return(-1);
24
+}
25
+
0 26
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+/*
2
+ * kakumei_pass.h
3
+ *
4
+ * Password handling for kakumei.
5
+ *
6
+ * Header file
7
+ *
8
+ * Author: Dario Rodriguez dario@softhome.net
9
+ * This progran is licensed under the terms of the Affero GPL v1+
10
+ */
11
+
12
+#include "kakumei.h"
13
+
14
+int pass_new(kakumei *ka, char *user, char *passwd);
15
+int pass_check(kakumei *ka, char *user, char *passwd);
16
+