b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 1 | #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.he | 3c80834 | 2025-05-29 10:43:28 +0800 | [diff] [blame] | 18 | #define PASSWR_MAX_LEN 128 |
lichengzhang | 4b22c34 | 2025-06-03 16:26:15 +0800 | [diff] [blame] | 19 | int32_t (*gsw_sec_set_loginpw)(char *login_name, char *pw, unsigned int); |
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 20 | void *dlHandle; |
| 21 | char *lynqLib = "/lib/libgsw_lib.so"; |
| 22 | |
| 23 | int main(int argc, char *argv[]) |
| 24 | { |
| 25 | int ret; |
xy.he | 3c80834 | 2025-05-29 10:43:28 +0800 | [diff] [blame] | 26 | char tmp1[PASSWR_MAX_LEN]; |
| 27 | char tmp2[PASSWR_MAX_LEN]; |
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 28 | if(argc != 3) |
| 29 | { |
| 30 | printf("parameter error,please input username and passwd\n"); |
| 31 | return -1; |
| 32 | } |
xy.he | 3c80834 | 2025-05-29 10:43:28 +0800 | [diff] [blame] | 33 | strncpy(tmp1, argv[1],PASSWR_MAX_LEN); |
| 34 | strncpy(tmp2, argv[2],PASSWR_MAX_LEN); |
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 35 | 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 | } |
lichengzhang | 4b22c34 | 2025-06-03 16:26:15 +0800 | [diff] [blame] | 42 | gsw_sec_set_loginpw=(int(*)(char *username, char *passwd, unsigned int))dlsym(dlHandle, "gsw_set_passwd"); |
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 43 | if(dlHandle == NULL) |
| 44 | { |
| 45 | printf("dlsym gsw_set_passwd fail\n"); |
| 46 | return -1; |
| 47 | } |
lichengzhang | 4b22c34 | 2025-06-03 16:26:15 +0800 | [diff] [blame] | 48 | ret = gsw_sec_set_loginpw(tmp1, tmp2, strlen(tmp2)); |
b.liu | 68a94c9 | 2025-05-24 12:53:41 +0800 | [diff] [blame] | 49 | 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 | } |