From 06476556a78fa9ed81948fcacdc07c808db39661 Mon Sep 17 00:00:00 2001 From: "Andrey V.Kosteltsev" Date: Sat, 24 Sep 2022 17:36:37 +0300 Subject: Add id command --- src/commands.c | 9 +++++++++ src/commands.h | 1 + src/main.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/src/commands.c b/src/commands.c index 64ea3e3..5418adc 100644 --- a/src/commands.c +++ b/src/commands.c @@ -59,6 +59,15 @@ int com_ls( char *arg ) return( system( syscom ) ); } +int com_id( char *arg ) +{ + if( !valid_argument( "id", arg ) ) + return( 1 ); + + sprintf (syscom, "id %s", arg); + return( system( syscom ) ); +} + int com_more( char *arg ) { if( !valid_argument( "more", arg ) ) diff --git a/src/commands.h b/src/commands.h index c9d975d..76058c1 100644 --- a/src/commands.h +++ b/src/commands.h @@ -30,6 +30,7 @@ extern COMMAND_LIST users; extern COMMAND_LIST *current; +extern int com_id( char *arg ); extern int com_ls( char *arg ); extern int com_more( char *arg ); extern int com_vi( char *arg ); diff --git a/src/main.c b/src/main.c index c950f40..885883a 100644 --- a/src/main.c +++ b/src/main.c @@ -61,6 +61,7 @@ COMMAND shell_admin_list[] = { { "delete", com_delete, "Delete FILE" }, { "list", com_ls, "List files in DIR" }, { "ls", com_ls, "Synonym for `list'" }, + { "id", com_id, "Print user identity" }, { "ping", com_ping, "Ping some host" }, { "pwd", com_pwd, "Print the current working directory" }, { "rename", com_rename, "Rename FILE to NEWNAME" }, @@ -79,6 +80,7 @@ COMMAND shell_operator_list[] = { { "delete", com_delete, "Delete FILE" }, { "list", com_ls, "List files in DIR" }, { "ls", com_ls, "Synonym for `list'" }, + { "id", com_id, "Print user identity" }, { "ping", com_ping, "Ping some host" }, { "pwd", com_pwd, "Print the current working directory" }, { "rename", com_rename, "Rename FILE to NEWNAME" }, @@ -97,6 +99,7 @@ COMMAND shell_user_list[] = { { "delete", com_delete, "Delete FILE" }, { "list", com_ls, "List files in DIR" }, { "ls", com_ls, "Synonym for `list'" }, + { "id", com_id, "Print user identity" }, { "ping", com_ping, "Ping some host" }, { "pwd", com_pwd, "Print the current working directory" }, { "rename", com_rename, "Rename FILE to NEWNAME" }, -- cgit v1.2.3