mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-05-31 01:10:55 +00:00
Provide default name for login
This commit is contained in:
parent
e32f34a063
commit
2ce70c02e3
3 changed files with 37 additions and 6 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2022-06-07 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* GNUMakefile: Fix to supply local flags to build libraries
|
||||||
|
* EcConsole.m: Use the EffectiveUser default or the name of the
|
||||||
|
user running the process as the default name to login with.
|
||||||
|
The user is still allowed to enter a name at the Login prompt.
|
||||||
|
|
||||||
2022-02-28 Richard Frith-Macdonald <rfm@gnu.org>
|
2022-02-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* EcCommand.m:
|
* EcCommand.m:
|
||||||
|
|
33
EcConsole.m
33
EcConsole.m
|
@ -61,6 +61,8 @@ static BOOL commandIsRepeat (NSString *string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NSString *originalUserName = nil;
|
||||||
|
|
||||||
@interface EcConsole : EcProcess <RunLoopEvents, Console>
|
@interface EcConsole : EcProcess <RunLoopEvents, Console>
|
||||||
{
|
{
|
||||||
NSFileHandle *ichan;
|
NSFileHandle *ichan;
|
||||||
|
@ -759,6 +761,7 @@ static BOOL commandIsRepeat (NSString *string)
|
||||||
|
|
||||||
- (id) initWithDefaults: (NSDictionary*)defs
|
- (id) initWithDefaults: (NSDictionary*)defs
|
||||||
{
|
{
|
||||||
|
ASSIGN(originalUserName, NSUserName());
|
||||||
self = [super initWithDefaults: defs];
|
self = [super initWithDefaults: defs];
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
|
@ -1051,9 +1054,20 @@ consoleCompleter(const char *text, int start, int end)
|
||||||
NSString *reject;
|
NSString *reject;
|
||||||
char buf[128], *line;
|
char buf[128], *line;
|
||||||
|
|
||||||
|
if (nil == (u = [[self cmdDefaults] stringForKey: @"EffectiveUser"]))
|
||||||
|
{
|
||||||
|
u = originalUserName;
|
||||||
|
}
|
||||||
|
|
||||||
/* read username */
|
/* read username */
|
||||||
|
if (u)
|
||||||
printf("Login: ");
|
{
|
||||||
|
printf("Login (%s): ", [u UTF8String]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Login: ");
|
||||||
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
line = fgets(buf, sizeof(buf), stdin);
|
line = fgets(buf, sizeof(buf), stdin);
|
||||||
|
@ -1064,12 +1078,19 @@ consoleCompleter(const char *text, int start, int end)
|
||||||
}
|
}
|
||||||
line[strlen(line) - 1] = '\0';
|
line[strlen(line) - 1] = '\0';
|
||||||
|
|
||||||
u = [[NSString stringWithCString: line] stringByTrimmingSpaces];
|
/* If we do not have a system username or if the user entered a value
|
||||||
if ([u length] == 0)
|
* we use the username entered (or try again).
|
||||||
|
*/
|
||||||
|
if (nil == u || line[0] != '\0')
|
||||||
{
|
{
|
||||||
/* user just pressed enter, retry */
|
u = [[NSString stringWithCString: line] stringByTrimmingSpaces];
|
||||||
continue;
|
if ([u length] == 0)
|
||||||
|
{
|
||||||
|
/* user just pressed enter, retry */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([u caseInsensitiveCompare: @"quit"] == NSOrderedSame)
|
if ([u caseInsensitiveCompare: @"quit"] == NSOrderedSame)
|
||||||
{
|
{
|
||||||
[self cmdQuit: 0];
|
[self cmdQuit: 0];
|
||||||
|
|
|
@ -74,14 +74,17 @@ TOOL_NAME = \
|
||||||
Command_OBJC_FILES = Command.m EcCommand.m EcClientI.m NSFileHandle+Printf.m
|
Command_OBJC_FILES = Command.m EcCommand.m EcClientI.m NSFileHandle+Printf.m
|
||||||
Command_TOOL_LIBS += -lECCL
|
Command_TOOL_LIBS += -lECCL
|
||||||
Command_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
Command_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||||
|
Command_CPPFLAGS += ${ECCL_CPPFLAGS}
|
||||||
|
|
||||||
Console_OBJC_FILES = Console.m EcConsole.m NSFileHandle+Printf.m
|
Console_OBJC_FILES = Console.m EcConsole.m NSFileHandle+Printf.m
|
||||||
Console_TOOL_LIBS += -lECCL
|
Console_TOOL_LIBS += -lECCL
|
||||||
Console_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
Console_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||||
|
Console_CPPFLAGS += ${ECCL_CPPFLAGS}
|
||||||
|
|
||||||
Control_OBJC_FILES = Control.m EcControl.m EcClientI.m NSFileHandle+Printf.m
|
Control_OBJC_FILES = Control.m EcControl.m EcClientI.m NSFileHandle+Printf.m
|
||||||
Control_TOOL_LIBS += -lECCL
|
Control_TOOL_LIBS += -lECCL
|
||||||
Control_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
Control_LIB_DIRS += -L./$(GNUSTEP_OBJ_DIR)
|
||||||
|
Control_CPPFLAGS += ${ECCL_CPPFLAGS}
|
||||||
|
|
||||||
AlarmTool_OBJC_FILES = AlarmTool.m
|
AlarmTool_OBJC_FILES = AlarmTool.m
|
||||||
AlarmTool_TOOL_LIBS += -lECCL
|
AlarmTool_TOOL_LIBS += -lECCL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue