blob: 925d531a72a7d69c5e5928a340f6f120c01916f3 [file] [log] [blame]
lichengzhang4b22c342025-06-03 16:26:15 +08001#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
15int32_t gsw_sec_set_loginpw(char *login_name, char *pw, unsigned int pw_len)
16{
17 int ret;
18 char cmd[256];
lichengzhang8e23d952025-07-21 11:10:49 +080019 if((login_name == NULL) || (pw == NULL) || (strlen(pw) != pw_len))
lichengzhang4b22c342025-06-03 16:26:15 +080020 {
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}