]> git.sur5r.net Git - ngadmin/blob - cli/com_password.c
4b1f184381050079d67f34bd4346d40a7ff25b77
[ngadmin] / cli / com_password.c
1
2 #include "common.h"
3
4
5
6
7 static bool do_password_change (const struct TreeNode *tn UNUSED, int nb, const char **com, struct ngadmin *nga) {
8  
9  int i;
10  const struct swi_attr *sa;
11  
12  
13  if ( nb!=1 ) {
14   printf("Usage: password set <value>\n");
15   return false;
16  }
17  
18  if ( (sa=ngadmin_getCurrentSwitch(nga))==NULL ) {
19   printf("must be logged\n");
20   return false;
21  }
22  
23  i=ngadmin_changePassword(nga, com[0]);
24  printErrCode(i);
25  
26  
27  return true;
28  
29 }
30
31
32
33 static bool do_password_set (const struct TreeNode *tn UNUSED, int nb, const char **com, struct ngadmin *nga) {
34  
35  int i;
36  
37  
38  if ( nb!=1 ) {
39   printf("Usage: password set <value>\n");
40   return false;
41  }
42  
43  i=ngadmin_setPassword(nga, com[0]);
44  printErrCode(i);
45  
46  
47  return true;
48  
49 }
50
51
52
53
54 static const struct TreeNode com_password_change=COM("change", do_password_change, true, NULL);
55 static const struct TreeNode com_password_set=COM("set", do_password_set, true, NULL);
56
57 const struct TreeNode com_password=COM("password", NULL, false, &com_password_change, &com_password_set, NULL);
58
59
60