source: rtems/cpukit/libmisc/shell/main_id.c @ 9a77af8

4.104.115
Last change on this file since 9a77af8 was 031deada, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/02/09 at 13:04:13

Add attribute((unused)) to unused function args.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  ID Command Implementation
3 *
4 *  Author: Fernando RUIZ CASAS
5 *  Work: fernando.ruiz@ctv.es
6 *  Home: correo@fernando-ruiz.com
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#ifdef HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19
20#include <stdio.h>
21#include <unistd.h>
22#include <string.h>
23#include <errno.h>
24#include <pwd.h>
25#include <grp.h>
26
27#include <rtems.h>
28#include <rtems/shell.h>
29#include "internal.h"
30
31int rtems_shell_main_id(
32  int   argc __attribute__((unused)),
33  char *argv[] __attribute__((unused))
34)
35{
36  struct passwd *pwd;
37  struct group  *grp;
38
39  pwd = getpwuid(getuid());
40  grp = getgrgid(getgid());
41  printf(
42    "uid=%d(%s),gid=%d(%s),",
43    getuid(),
44    (pwd) ? pwd->pw_name : "",
45    getgid(),
46    (grp) ? grp->gr_name : ""
47  );
48  pwd = getpwuid(geteuid());
49  grp = getgrgid(getegid());
50  printf(
51    "euid=%d(%s),egid=%d(%s)\n",
52    geteuid(),
53    (pwd) ? pwd->pw_name : "",
54    getegid(),
55    (grp) ? grp->gr_name : ""
56  );
57  return 0;
58}
59
60rtems_shell_cmd_t rtems_shell_ID_Command = {
61  "id",                                      /* name */
62  "show uid, gid, euid, and egid",           /* usage */
63  "misc",                                    /* topic */
64  rtems_shell_main_id,                       /* command */
65  NULL,                                      /* alias */
66  NULL                                       /* next */
67};
Note: See TracBrowser for help on using the repository browser.