| #include <stdio.h> |
| #include <string.h> |
| #include <strings.h> |
| #include <stdlib.h> |
| #include <errno.h> |
| #include <fcntl.h> |
| #include <signal.h> |
| #include <sys/types.h> |
| #include <unistd.h> |
| #include <pthread.h> |
| #include <termios.h> |
| #include <time.h> |
| #include <sys/ioctl.h> |
| #include <dlfcn.h> |
| #include <stdint.h> |
| #include <stdbool.h> |
| |
| #define PASSWR_MAX_LEN 128 |
| int32_t (*gsw_sec_set_loginpw)(char *login_name, char *pw, unsigned int); |
| void *dlHandle; |
| char *lynqLib = "/lib/libgsw_lib.so"; |
| |
| int main(int argc, char *argv[]) |
| { |
| int ret; |
| char tmp1[PASSWR_MAX_LEN]; |
| char tmp2[PASSWR_MAX_LEN]; |
| if(argc != 3) |
| { |
| printf("parameter error,please input username and passwd\n"); |
| return -1; |
| } |
| strncpy(tmp1, argv[1],PASSWR_MAX_LEN); |
| strncpy(tmp2, argv[2],PASSWR_MAX_LEN); |
| printf("username is %s, passwd is %s\n",tmp1, tmp2); |
| dlHandle = dlopen(lynqLib, RTLD_NOW); |
| if(dlHandle == NULL) |
| { |
| printf("dlopen libgsw_lib fail\n"); |
| return -1; |
| } |
| gsw_sec_set_loginpw=(int(*)(char *username, char *passwd, unsigned int))dlsym(dlHandle, "gsw_set_passwd"); |
| if(dlHandle == NULL) |
| { |
| printf("dlsym gsw_set_passwd fail\n"); |
| return -1; |
| } |
| ret = gsw_sec_set_loginpw(tmp1, tmp2, strlen(tmp2)); |
| if(ret) |
| { |
| printf("gsw_set_passwd fail\n"); |
| } |
| else |
| { |
| printf("gsw_set_passwd successful\n"); |
| } |
| |
| return 0; |
| } |