File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ #define _GNU_SOURCE
2+ #include <stdio.h>
3+ #include <stdlib.h>
4+ #include <string.h>
5+ #include <strings.h>
6+
7+ int IsUserLogin (char * user , int bufsize )
8+ {
9+ FILE * fp = NULL ;
10+ char buf [1024 ];
11+ int login = 0 ;
12+
13+ bzero (user , bufsize );
14+ fp = popen ("/usr/syno/synoman/webman/modules/authenticate.cgi" , "r" );
15+ if (!fp ) {
16+ return 0 ;
17+ }
18+
19+ bzero (buf , sizeof (buf ));
20+ fread (buf , 1024 , 1 , fp );
21+
22+ if (strlen (buf ) > 0 ) {
23+ snprintf (user , bufsize , "%s" , buf );
24+ login = 1 ;
25+ }
26+ pclose (fp );
27+
28+ return login ;
29+ }
30+
31+ int main (int argc , char * * argv )
32+ {
33+ char user [256 ];
34+ printf ("Content-Type: text/html\r\n\r\n" );
35+
36+ if (IsUserLogin (user , sizeof (user )) == 1 ) {
37+ printf ("User is authenticated. Name: %s\n" , user ); }
38+ else {
39+ printf ("User is not authenticated.\n" );
40+ }
41+
42+ return 0 ;
43+ }
44+
You can’t perform that action at this time.
0 commit comments