Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /**
0002  * @file
0003  * 
0004  * @brief WHOAMI Shell Command Implmentation
0005  */
0006 
0007 /*
0008  * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com>
0009  *
0010  *  The license and distribution terms for this file may be
0011  *  found in the file LICENSE in this distribution or at
0012  *  http://www.rtems.org/license/LICENSE.
0013  */
0014 
0015 #ifdef HAVE_CONFIG_H
0016 #include "config.h"
0017 #endif
0018 
0019 #include <stdio.h>
0020 #include <unistd.h>
0021 #include <string.h>
0022 #include <errno.h>
0023 #include <pwd.h>
0024 
0025 #include <rtems.h>
0026 #include <rtems/shell.h>
0027 #include "internal.h"
0028 
0029 static int rtems_shell_main_whoami(
0030   int   argc RTEMS_UNUSED,
0031   char *argv[] RTEMS_UNUSED
0032 )
0033 {
0034   struct passwd *pwd;
0035 
0036   pwd = getpwuid(geteuid());
0037   printf( "%s\n", (pwd) ? pwd->pw_name : "nobody");
0038   return 0;
0039 }
0040 
0041 rtems_shell_cmd_t rtems_shell_WHOAMI_Command = {
0042   "whoami",                                   /* name */
0043   "show current user",                        /* usage */
0044   "misc",                                     /* topic */
0045   rtems_shell_main_whoami,                    /* command */
0046   NULL,                                       /* alias */
0047   NULL                                        /* next */
0048 };