mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-03 08:22:44 +00:00
Fix broken layout help (this is what broke the TCP help screen).
Allow DITEM_NO_ECHO to be encoded in layout field types and make user.c use it for the password item.
This commit is contained in:
parent
55188e693a
commit
431285ea2b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=22099
@ -347,18 +347,17 @@ Mount(char *mountp, void *dev)
|
||||
WINDOW *
|
||||
openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height)
|
||||
{
|
||||
WINDOW *win;
|
||||
char help[FILENAME_MAX];
|
||||
|
||||
WINDOW *win;
|
||||
static char help[FILENAME_MAX];
|
||||
|
||||
/* We need a curses window */
|
||||
win = newwin(LINES, COLS, 0, 0);
|
||||
if (win) {
|
||||
/* Say where our help comes from */
|
||||
if (helpfile) {
|
||||
systemHelpFile(helpfile, help);
|
||||
use_helpfile(help);
|
||||
use_helpline("Press F1 for more information on this screen.");
|
||||
use_helpfile(systemHelpFile(helpfile, help));
|
||||
}
|
||||
|
||||
/* Setup a nice screen for us to splat stuff onto */
|
||||
draw_box(win, y, x, height, width, dialog_attr, border_attr);
|
||||
wattrset(win, dialog_attr);
|
||||
@ -378,10 +377,13 @@ initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
|
||||
|
||||
n = 0;
|
||||
while (layout[n].help != NULL) {
|
||||
switch (layout[n].type) {
|
||||
int t = TYPE_OF_OBJ(layout[n].type);
|
||||
|
||||
switch (t) {
|
||||
case STRINGOBJ:
|
||||
layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var,
|
||||
layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen);
|
||||
((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type);
|
||||
break;
|
||||
|
||||
case BUTTONOBJ:
|
||||
@ -391,7 +393,7 @@ initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
|
||||
default:
|
||||
msgFatal("Don't support this object yet!");
|
||||
}
|
||||
AddObj(&obj, layout[n].type, (void *) layout[n].obj);
|
||||
AddObj(&obj, t, (void *) layout[n].obj);
|
||||
n++;
|
||||
}
|
||||
*max = n - 1;
|
||||
@ -412,6 +414,7 @@ layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max,
|
||||
help_line[i] = '\0';
|
||||
use_helpline(help_line);
|
||||
display_helpline(win, LINES - 1, COLS - 1);
|
||||
wrefresh(win);
|
||||
|
||||
/* Ask for libdialog to do its stuff */
|
||||
ret = PollObj(obj);
|
||||
|
@ -186,6 +186,10 @@ typedef struct _variable {
|
||||
char *value;
|
||||
} Variable;
|
||||
|
||||
#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16))
|
||||
#define TYPE_OF_OBJ(type) ((type) & 0xff)
|
||||
#define ATTR_OF_OBJ(type) ((type) >> 16)
|
||||
|
||||
/* A screen layout structure */
|
||||
typedef struct _layout {
|
||||
int y; /* x & Y co-ordinates */
|
||||
|
@ -122,7 +122,7 @@ static Layout userLayout[] = {
|
||||
#define LAYOUT_PASSWD 3
|
||||
{ 3, 43, 15, PASSWD_FIELD_LEN - 1,
|
||||
"Password:", "The password for this user (enter this field with care!)",
|
||||
passwd, STRINGOBJ, NULL },
|
||||
passwd, NO_ECHO_OBJ(STRINGOBJ), NULL },
|
||||
#define LAYOUT_GECOS 4
|
||||
{ 8, 6, 33, GECOS_FIELD_LEN - 1,
|
||||
"Full name:", "The user's full name (comment)",
|
||||
@ -368,15 +368,15 @@ userAddGroup(dialogMenuItem *self)
|
||||
|
||||
reenter:
|
||||
cancelbutton = okbutton = 0;
|
||||
while (layoutDialogLoop(ds_win, groupLayout, &obj, &n, max, &cancelbutton, &cancel)) {
|
||||
if (firsttime && n == LAYOUT_GNAME) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeGroup();
|
||||
RefreshStringObj(groupLayout[LAYOUT_GID].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
if (firsttime) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeGroup();
|
||||
RefreshStringObj(groupLayout[LAYOUT_GID].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
|
||||
while (layoutDialogLoop(ds_win, groupLayout, &obj, &n, max, &cancelbutton, &cancel));
|
||||
|
||||
if (!cancel && !verifyGroupSettings())
|
||||
goto reenter;
|
||||
|
||||
@ -693,20 +693,20 @@ userAddUser(dialogMenuItem *self)
|
||||
|
||||
reenter:
|
||||
cancelbutton = okbutton = 0;
|
||||
while (layoutDialogLoop(ds_win, userLayout, &obj, &n, max, &cancelbutton, &cancel)) {
|
||||
if (firsttime && n == LAYOUT_UNAME) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeUser();
|
||||
RefreshStringObj(userLayout[LAYOUT_UID].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UGROUP].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_GECOS].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UMEMB].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_HOMEDIR].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_SHELL].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
if (firsttime) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeUser();
|
||||
RefreshStringObj(userLayout[LAYOUT_UID].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UGROUP].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_GECOS].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UMEMB].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_HOMEDIR].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_SHELL].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
|
||||
while (layoutDialogLoop(ds_win, userLayout, &obj, &n, max, &cancelbutton, &cancel));
|
||||
|
||||
if (!cancel && !verifyUserSettings(ds_win))
|
||||
goto reenter;
|
||||
|
||||
|
@ -347,18 +347,17 @@ Mount(char *mountp, void *dev)
|
||||
WINDOW *
|
||||
openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height)
|
||||
{
|
||||
WINDOW *win;
|
||||
char help[FILENAME_MAX];
|
||||
|
||||
WINDOW *win;
|
||||
static char help[FILENAME_MAX];
|
||||
|
||||
/* We need a curses window */
|
||||
win = newwin(LINES, COLS, 0, 0);
|
||||
if (win) {
|
||||
/* Say where our help comes from */
|
||||
if (helpfile) {
|
||||
systemHelpFile(helpfile, help);
|
||||
use_helpfile(help);
|
||||
use_helpline("Press F1 for more information on this screen.");
|
||||
use_helpfile(systemHelpFile(helpfile, help));
|
||||
}
|
||||
|
||||
/* Setup a nice screen for us to splat stuff onto */
|
||||
draw_box(win, y, x, height, width, dialog_attr, border_attr);
|
||||
wattrset(win, dialog_attr);
|
||||
@ -378,10 +377,13 @@ initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
|
||||
|
||||
n = 0;
|
||||
while (layout[n].help != NULL) {
|
||||
switch (layout[n].type) {
|
||||
int t = TYPE_OF_OBJ(layout[n].type);
|
||||
|
||||
switch (t) {
|
||||
case STRINGOBJ:
|
||||
layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var,
|
||||
layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen);
|
||||
((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type);
|
||||
break;
|
||||
|
||||
case BUTTONOBJ:
|
||||
@ -391,7 +393,7 @@ initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
|
||||
default:
|
||||
msgFatal("Don't support this object yet!");
|
||||
}
|
||||
AddObj(&obj, layout[n].type, (void *) layout[n].obj);
|
||||
AddObj(&obj, t, (void *) layout[n].obj);
|
||||
n++;
|
||||
}
|
||||
*max = n - 1;
|
||||
@ -412,6 +414,7 @@ layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max,
|
||||
help_line[i] = '\0';
|
||||
use_helpline(help_line);
|
||||
display_helpline(win, LINES - 1, COLS - 1);
|
||||
wrefresh(win);
|
||||
|
||||
/* Ask for libdialog to do its stuff */
|
||||
ret = PollObj(obj);
|
||||
|
@ -186,6 +186,10 @@ typedef struct _variable {
|
||||
char *value;
|
||||
} Variable;
|
||||
|
||||
#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16))
|
||||
#define TYPE_OF_OBJ(type) ((type) & 0xff)
|
||||
#define ATTR_OF_OBJ(type) ((type) >> 16)
|
||||
|
||||
/* A screen layout structure */
|
||||
typedef struct _layout {
|
||||
int y; /* x & Y co-ordinates */
|
||||
|
@ -347,18 +347,17 @@ Mount(char *mountp, void *dev)
|
||||
WINDOW *
|
||||
openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height)
|
||||
{
|
||||
WINDOW *win;
|
||||
char help[FILENAME_MAX];
|
||||
|
||||
WINDOW *win;
|
||||
static char help[FILENAME_MAX];
|
||||
|
||||
/* We need a curses window */
|
||||
win = newwin(LINES, COLS, 0, 0);
|
||||
if (win) {
|
||||
/* Say where our help comes from */
|
||||
if (helpfile) {
|
||||
systemHelpFile(helpfile, help);
|
||||
use_helpfile(help);
|
||||
use_helpline("Press F1 for more information on this screen.");
|
||||
use_helpfile(systemHelpFile(helpfile, help));
|
||||
}
|
||||
|
||||
/* Setup a nice screen for us to splat stuff onto */
|
||||
draw_box(win, y, x, height, width, dialog_attr, border_attr);
|
||||
wattrset(win, dialog_attr);
|
||||
@ -378,10 +377,13 @@ initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
|
||||
|
||||
n = 0;
|
||||
while (layout[n].help != NULL) {
|
||||
switch (layout[n].type) {
|
||||
int t = TYPE_OF_OBJ(layout[n].type);
|
||||
|
||||
switch (t) {
|
||||
case STRINGOBJ:
|
||||
layout[n].obj = NewStringObj(win, layout[n].prompt, layout[n].var,
|
||||
layout[n].y + y, layout[n].x + x, layout[n].len, layout[n].maxlen);
|
||||
((StringObj *)layout[n].obj)->attr_mask = ATTR_OF_OBJ(layout[n].type);
|
||||
break;
|
||||
|
||||
case BUTTONOBJ:
|
||||
@ -391,7 +393,7 @@ initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max)
|
||||
default:
|
||||
msgFatal("Don't support this object yet!");
|
||||
}
|
||||
AddObj(&obj, layout[n].type, (void *) layout[n].obj);
|
||||
AddObj(&obj, t, (void *) layout[n].obj);
|
||||
n++;
|
||||
}
|
||||
*max = n - 1;
|
||||
@ -412,6 +414,7 @@ layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max,
|
||||
help_line[i] = '\0';
|
||||
use_helpline(help_line);
|
||||
display_helpline(win, LINES - 1, COLS - 1);
|
||||
wrefresh(win);
|
||||
|
||||
/* Ask for libdialog to do its stuff */
|
||||
ret = PollObj(obj);
|
||||
|
@ -186,6 +186,10 @@ typedef struct _variable {
|
||||
char *value;
|
||||
} Variable;
|
||||
|
||||
#define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16))
|
||||
#define TYPE_OF_OBJ(type) ((type) & 0xff)
|
||||
#define ATTR_OF_OBJ(type) ((type) >> 16)
|
||||
|
||||
/* A screen layout structure */
|
||||
typedef struct _layout {
|
||||
int y; /* x & Y co-ordinates */
|
||||
|
@ -122,7 +122,7 @@ static Layout userLayout[] = {
|
||||
#define LAYOUT_PASSWD 3
|
||||
{ 3, 43, 15, PASSWD_FIELD_LEN - 1,
|
||||
"Password:", "The password for this user (enter this field with care!)",
|
||||
passwd, STRINGOBJ, NULL },
|
||||
passwd, NO_ECHO_OBJ(STRINGOBJ), NULL },
|
||||
#define LAYOUT_GECOS 4
|
||||
{ 8, 6, 33, GECOS_FIELD_LEN - 1,
|
||||
"Full name:", "The user's full name (comment)",
|
||||
@ -368,15 +368,15 @@ userAddGroup(dialogMenuItem *self)
|
||||
|
||||
reenter:
|
||||
cancelbutton = okbutton = 0;
|
||||
while (layoutDialogLoop(ds_win, groupLayout, &obj, &n, max, &cancelbutton, &cancel)) {
|
||||
if (firsttime && n == LAYOUT_GNAME) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeGroup();
|
||||
RefreshStringObj(groupLayout[LAYOUT_GID].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
if (firsttime) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeGroup();
|
||||
RefreshStringObj(groupLayout[LAYOUT_GID].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
|
||||
while (layoutDialogLoop(ds_win, groupLayout, &obj, &n, max, &cancelbutton, &cancel));
|
||||
|
||||
if (!cancel && !verifyGroupSettings())
|
||||
goto reenter;
|
||||
|
||||
@ -693,20 +693,20 @@ userAddUser(dialogMenuItem *self)
|
||||
|
||||
reenter:
|
||||
cancelbutton = okbutton = 0;
|
||||
while (layoutDialogLoop(ds_win, userLayout, &obj, &n, max, &cancelbutton, &cancel)) {
|
||||
if (firsttime && n == LAYOUT_UNAME) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeUser();
|
||||
RefreshStringObj(userLayout[LAYOUT_UID].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UGROUP].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_GECOS].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UMEMB].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_HOMEDIR].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_SHELL].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
if (firsttime) {
|
||||
/* fill in the blanks, well, just the GID */
|
||||
completeUser();
|
||||
RefreshStringObj(userLayout[LAYOUT_UID].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UGROUP].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_GECOS].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_UMEMB].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_HOMEDIR].obj);
|
||||
RefreshStringObj(userLayout[LAYOUT_SHELL].obj);
|
||||
firsttime = FALSE;
|
||||
}
|
||||
|
||||
while (layoutDialogLoop(ds_win, userLayout, &obj, &n, max, &cancelbutton, &cancel));
|
||||
|
||||
if (!cancel && !verifyUserSettings(ds_win))
|
||||
goto reenter;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user