lichengzhang | 4b22c34 | 2025-06-03 16:26:15 +0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include <fcntl.h> |
| 4 | #include <sys/types.h> |
| 5 | #include <sys/stat.h> |
| 6 | #include <string.h> |
| 7 | #include <errno.h> |
| 8 | #include <termios.h> |
| 9 | #include <unistd.h> |
| 10 | #include <stdint.h> |
| 11 | #include <sys/ioctl.h> |
| 12 | #include <dlfcn.h> |
| 13 | #include "gsw_hal_errcode.h" |
| 14 | |
| 15 | int32_t gsw_sec_set_loginpw(char *login_name, char *pw, unsigned int pw_len) |
| 16 | { |
| 17 | int ret; |
| 18 | char cmd[256]; |
lichengzhang | 8e23d95 | 2025-07-21 11:10:49 +0800 | [diff] [blame] | 19 | if((login_name == NULL) || (pw == NULL) || (strlen(pw) != pw_len)) |
lichengzhang | 4b22c34 | 2025-06-03 16:26:15 +0800 | [diff] [blame] | 20 | { |
| 21 | return GSW_HAL_NORMAL_FAIL; |
| 22 | } |
| 23 | sprintf(cmd, "echo \"%s:%s\"|chpasswd", login_name, pw); |
| 24 | ret = system(cmd); |
| 25 | if (ret != 0 ) |
| 26 | return GSW_HAL_NORMAL_FAIL; |
| 27 | else |
| 28 | return GSW_HAL_SUCCESS; |
| 29 | } |