Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144104960
D53301.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D53301.diff
View Options
diff --git a/usr.bin/id/id.1 b/usr.bin/id/id.1
--- a/usr.bin/id/id.1
+++ b/usr.bin/id/id.1
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 5, 2011
+.Dd October 23, 2025
.Dt ID 1
.Os
.Sh NAME
@@ -50,12 +50,18 @@
.Nm
.Fl c
.Nm
+.Fl d
+.Op Ar user
+.Nm
.Fl g Op Fl nr
.Op Ar user
.Nm
.Fl p
.Op Ar user
.Nm
+.Fl s
+.Op Ar user
+.Nm
.Fl u Op Fl nr
.Op Ar user
.Sh DESCRIPTION
@@ -90,6 +96,8 @@
implementations.
.It Fl c
Display current login class.
+.It Fl d
+Display the home directory of the current or specified user.
.It Fl g
Display the effective group ID as a number.
.It Fl n
@@ -128,6 +136,8 @@
and
.Fl u
options instead of the effective ID.
+.It Fl s
+Display the shell of the current or specified user.
.It Fl u
Display the effective user ID as a number.
.El
@@ -174,8 +184,20 @@
.Sh STANDARDS
The
.Nm
-function is expected to conform to
-.St -p1003.2 .
+utility is expected to conform to
+.St -p1003.1-2024 .
+The
+.Fl A ,
+.Fl M ,
+.Fl P ,
+.Fl c ,
+.Fl d ,
+.Fl p ,
+and
+.Fl s
+options are
+.Fx
+extensions.
.Sh HISTORY
The
historic
diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c
--- a/usr.bin/id/id.c
+++ b/usr.bin/id/id.c
@@ -55,6 +55,8 @@
#endif
static void group(struct passwd *, bool);
static void maclabel(void);
+static void dir(struct passwd *);
+static void shell(struct passwd *);
static void usage(void);
static struct passwd *who(char *);
@@ -69,7 +71,7 @@
bool Aflag;
#endif
bool Gflag, Mflag, Pflag;
- bool cflag, gflag, nflag, pflag, rflag, uflag;
+ bool cflag, dflag, gflag, nflag, pflag, rflag, sflag, uflag;
int ch, combo, error, id;
const char *myname, *optstr;
char loginclass[MAXLOGNAME];
@@ -78,10 +80,10 @@
Aflag = false;
#endif
Gflag = Mflag = Pflag = false;
- cflag = gflag = nflag = pflag = rflag = uflag = false;
+ cflag = dflag = gflag = nflag = pflag = rflag = sflag = uflag = false;
myname = getprogname();
- optstr = "AGMPacgnpru";
+ optstr = "AGMPacdgnprsu";
if (strcmp(myname, "groups") == 0) {
isgroups = true;
optstr = "";
@@ -114,6 +116,9 @@
case 'c':
cflag = true;
break;
+ case 'd':
+ dflag = true;
+ break;
case 'g':
gflag = true;
break;
@@ -126,6 +131,9 @@
case 'r':
rflag = true;
break;
+ case 's':
+ sflag = true;
+ break;
case 'u':
uflag = true;
break;
@@ -142,6 +150,8 @@
usage();
combo = Aflag + Gflag + Mflag + Pflag + gflag + pflag + uflag;
+ if (combo + dflag + sflag > 1)
+ usage();
if (combo > 1)
usage();
if (combo == 0 && (nflag || rflag))
@@ -185,6 +195,11 @@
exit(0);
}
+ if (dflag) {
+ dir(pw);
+ exit(0);
+ }
+
if (Gflag) {
group(pw, nflag);
exit(0);
@@ -205,6 +220,11 @@
exit(0);
}
+ if (sflag) {
+ shell(pw);
+ exit(0);
+ }
+
id_print(pw);
exit(0);
}
@@ -464,6 +484,26 @@
pw->pw_dir, pw->pw_shell);
}
+static void
+dir(struct passwd *pw)
+{
+ if (pw == NULL) {
+ if ((pw = getpwuid(getuid())) == NULL)
+ err(1, "getpwuid");
+ }
+ printf("%s\n", pw->pw_dir);
+}
+
+static void
+shell(struct passwd *pw)
+{
+ if (pw == NULL) {
+ if ((pw = getpwuid(getuid())) == NULL)
+ err(1, "getpwuid");
+ }
+ printf("%s\n", pw->pw_shell);
+}
+
static void
usage(void)
{
@@ -481,8 +521,10 @@
" id -M\n"
" id -P [user]\n"
" id -c\n"
+ " id -d [user]\n"
" id -g [-nr] [user]\n"
" id -p [user]\n"
+ " id -s [user]\n"
" id -u [-nr] [user]\n");
exit(1);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 5, 8:20 PM (14 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28443892
Default Alt Text
D53301.diff (3 KB)
Attached To
Mode
D53301: id: Add -d and -s options
Attached
Detach File
Event Timeline
Log In to Comment