X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci2%2Fui.git;a=blobdiff_plain;f=luci2%2Fsrc%2Fio%2Fmain.c;h=1ad230db95b10a57e1b3db90d1631fab05141a1b;hp=478e1436196ca39242c0f486b0d58131f82971da;hb=69a02246818bd6a13c10c1ccd4cf9ff141e3849f;hpb=a598c3ca618640f3149208a5e4ef60d8569b8a89 diff --git a/luci2/src/io/main.c b/luci2/src/io/main.c index 478e143..1ad230d 100644 --- a/luci2/src/io/main.c +++ b/luci2/src/io/main.c @@ -16,9 +16,6 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define _GNU_SOURCE -#define _XOPEN_SOURCE 700 - #include #include #include @@ -33,11 +30,6 @@ #include #include -#ifdef HAVE_SHADOW -#include -#endif - -#include "login.h" #include "multipart_parser.h" @@ -641,71 +633,12 @@ main_backup(int argc, char **argv) } } -static int -main_login(int argc, char **argv) -{ - char *hash, *fields[] = { "username", NULL, "password", NULL }; - const char *sid = NULL; - - if (postdecode(fields, 2)) - { -#ifdef HAVE_SHADOW - struct spwd *sp = getspnam(fields[1]); - - if (!sp) - goto inval; - - /* check whether a password is set */ - if (sp->sp_pwdp && *sp->sp_pwdp && - strcmp(sp->sp_pwdp, "!") && strcmp(sp->sp_pwdp, "x")) - { - hash = crypt(fields[3], sp->sp_pwdp); - - if (strcmp(hash, sp->sp_pwdp)) - goto inval; - } -#else - struct passwd *pw = getpwnam(fields[1]); - - if (!pw) - goto inval; - - /* check whether a password is set */ - if (pw->pw_passwd && *pw->pw_passwd && - strcmp(pw->pw_passwd, "!") && strcmp(pw->pw_passwd, "x")) - { - hash = crypt(fields[3], pw->pw_passwd); - - if (strcmp(hash, pw->pw_passwd)) - goto inval; - } -#endif - - sid = setup_session(fields[1]); - - if (!sid) - goto inval; - - printf("Status: 200 OK\r\n"); - printf("Content-Type: application/json\r\n\r\n{\n"); - printf("\t\"sessionid\": \"%s\"\n}\n", sid); - return 0; - } - -inval: - printf("Status: 200 OK\r\n"); - printf("Content-Type: application/json\r\n\r\n{}\n"); - return 1; -} - int main(int argc, char **argv) { if (strstr(argv[0], "luci-upload")) return main_upload(argc, argv); else if (strstr(argv[0], "luci-backup")) return main_backup(argc, argv); - else if (strstr(argv[0], "luci-login")) - return main_login(argc, argv); return -1; }