blob: 13d722acb775fd0969c0832dbe951e03d9b79ff5 [file] [log] [blame]
b.liu68a94c92025-05-24 12:53:41 +08001#include <stdio.h>
2#include <string.h>
3#include <strings.h>
4#include <stdlib.h>
5#include <errno.h>
6#include <fcntl.h>
7#include <signal.h>
8#include <sys/types.h>
9#include <unistd.h>
10#include <pthread.h>
11#include <termios.h>
12#include <time.h>
13#include <sys/ioctl.h>
14#include <dlfcn.h>
15#include <stdint.h>
16#include <stdbool.h>
17
xy.he3c808342025-05-29 10:43:28 +080018#define PASSWR_MAX_LEN 128
lichengzhang4b22c342025-06-03 16:26:15 +080019int32_t (*gsw_sec_set_loginpw)(char *login_name, char *pw, unsigned int);
b.liu68a94c92025-05-24 12:53:41 +080020void *dlHandle;
21char *lynqLib = "/lib/libgsw_lib.so";
22
23int main(int argc, char *argv[])
24{
25 int ret;
xy.he3c808342025-05-29 10:43:28 +080026 char tmp1[PASSWR_MAX_LEN];
27 char tmp2[PASSWR_MAX_LEN];
b.liu68a94c92025-05-24 12:53:41 +080028 if(argc != 3)
29 {
30 printf("parameter error,please input username and passwd\n");
31 return -1;
32 }
xy.he3c808342025-05-29 10:43:28 +080033 strncpy(tmp1, argv[1],PASSWR_MAX_LEN);
34 strncpy(tmp2, argv[2],PASSWR_MAX_LEN);
b.liu68a94c92025-05-24 12:53:41 +080035 printf("username is %s, passwd is %s\n",tmp1, tmp2);
36 dlHandle = dlopen(lynqLib, RTLD_NOW);
37 if(dlHandle == NULL)
38 {
39 printf("dlopen libgsw_lib fail\n");
40 return -1;
41 }
lichengzhang4b22c342025-06-03 16:26:15 +080042 gsw_sec_set_loginpw=(int(*)(char *username, char *passwd, unsigned int))dlsym(dlHandle, "gsw_set_passwd");
b.liu68a94c92025-05-24 12:53:41 +080043 if(dlHandle == NULL)
44 {
45 printf("dlsym gsw_set_passwd fail\n");
46 return -1;
47 }
lichengzhang4b22c342025-06-03 16:26:15 +080048 ret = gsw_sec_set_loginpw(tmp1, tmp2, strlen(tmp2));
b.liu68a94c92025-05-24 12:53:41 +080049 if(ret)
50 {
51 printf("gsw_set_passwd fail\n");
52 }
53 else
54 {
55 printf("gsw_set_passwd successful\n");
56 }
57
58 return 0;
59}