time_t present; /* who where present at time_t */
unsigned int time_fmt; /* time format */
char separator; /* output separator */
+
+ bool fullnames_mode;
};
/* Double linked list of struct utmp's */
if (r < 0)
mem2strcpy(domain, p->ut_host, sizeof(p->ut_host), sizeof(domain));
+ /*
+ * set last displayed character to an asterisk when
+ * user/domain/ip fields are to be truncated in non-fullnames mode
+ */
+ if (!ctl->fullnames_mode && (strnlen(p->ut_user, sizeof(p->ut_user)) > ctl->name_len))
+ p->ut_user[ctl->name_len-1] = '*';
+
if (ctl->showhost) {
if (!ctl->altlist) {
+
+ if (!ctl->fullnames_mode && (strnlen(domain, sizeof(domain)) > ctl->domain_len))
+ domain[ctl->domain_len-1] = '*';
+
len = snprintf(final, sizeof(final),
"%-8.*s%c%-12.12s%c%-16.*s%c%-*.*s%c%-*.*s%c%s\n",
ctl->name_len, p->ut_user, ctl->separator, utline, ctl->separator,
.showhost = TRUE,
.name_len = LAST_LOGIN_LEN,
.time_fmt = LAST_TIMEFTM_SHORT,
- .domain_len = LAST_DOMAIN_LEN
+ .domain_len = LAST_DOMAIN_LEN,
+ .fullnames_mode = false,
};
char **files = NULL;
size_t i, nfiles = 0;
ctl.until = (time_t) (p / 1000000);
break;
case 'w':
+ ctl.fullnames_mode = true;
if (ctl.name_len < sizeof_member(struct utmpx, ut_user))
ctl.name_len = sizeof_member(struct utmpx, ut_user);
if (ctl.domain_len < sizeof_member(struct utmpx, ut_host))
~~~ basic output ~~~
-rick long never-gonna-logo Thu Jan 1 00:00 - 03:14 (24855+03:14)
+rick long never-gonna-log* Thu Jan 1 00:00 - 03:14 (24855+03:14)
torvalds linux hobby Mon Aug 26 00:57 gone - no logout
reboot system boot system-name Wed Aug 28 18:00 still running
reboot system boot system-name Wed Aug 28 16:00 - 17:00 (01:00)
oldtime foo four Wed Aug 28 08:00 - 09:00 (01:00)
init foo five Wed Aug 28 07:00 - 08:00 (01:00)
login foo six Wed Aug 28 06:00 - 07:00 (01:00)
-user_pro foo seven Wed Aug 28 05:00 - 06:00 (01:00)
-accounti foo nine Wed Aug 28 03:00 - 04:00 (01:00)
+user_pr* foo seven Wed Aug 28 05:00 - 06:00 (01:00)
+account* foo nine Wed Aug 28 03:00 - 04:00 (01:00)
wtmp-a begins Wed Aug 28 03:00:00 2013
~~~ include system ~~~
-rick long never-gonna-logo Thu Jan 1 00:00 - 03:14 (24855+03:14)
+rick long never-gonna-log* Thu Jan 1 00:00 - 03:14 (24855+03:14)
torvalds linux hobby Mon Aug 26 00:57 gone - no logout
reboot system boot system-name Wed Aug 28 18:00 still running
shutdown system down system-name Wed Aug 28 17:00 - 18:00 (01:00)
oldtime foo four Wed Aug 28 08:00 - 09:00 (01:00)
init foo five Wed Aug 28 07:00 - 08:00 (01:00)
login foo six Wed Aug 28 06:00 - 07:00 (01:00)
-user_pro foo seven Wed Aug 28 05:00 - 06:00 (01:00)
-accounti foo nine Wed Aug 28 03:00 - 04:00 (01:00)
+user_pr* foo seven Wed Aug 28 05:00 - 06:00 (01:00)
+account* foo nine Wed Aug 28 03:00 - 04:00 (01:00)
wtmp-a begins Wed Aug 28 03:00:00 2013
~~~ show ip ~~~
wtmp-a begins Wed Aug 28 03:00:00 2013
~~~ full times shortopt ~~~
-rick long never-gonna-logo Thu Jan 1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14)
+rick long never-gonna-log* Thu Jan 1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14)
torvalds linux hobby Mon Aug 26 00:57:08 1991 gone - no logout
reboot system boot system-name Wed Aug 28 18:00:00 2013 still running
reboot system boot system-name Wed Aug 28 16:00:00 2013 - Wed Aug 28 17:00:00 2013 (01:00)
oldtime foo four Wed Aug 28 08:00:00 2013 - Wed Aug 28 09:00:00 2013 (01:00)
init foo five Wed Aug 28 07:00:00 2013 - Wed Aug 28 08:00:00 2013 (01:00)
login foo six Wed Aug 28 06:00:00 2013 - Wed Aug 28 07:00:00 2013 (01:00)
-user_pro foo seven Wed Aug 28 05:00:00 2013 - Wed Aug 28 06:00:00 2013 (01:00)
-accounti foo nine Wed Aug 28 03:00:00 2013 - Wed Aug 28 04:00:00 2013 (01:00)
+user_pr* foo seven Wed Aug 28 05:00:00 2013 - Wed Aug 28 06:00:00 2013 (01:00)
+account* foo nine Wed Aug 28 03:00:00 2013 - Wed Aug 28 04:00:00 2013 (01:00)
wtmp-a begins Wed Aug 28 03:00:00 2013
~~~ full times longopt ~~~
-rick long never-gonna-logo Thu Jan 1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14)
+rick long never-gonna-log* Thu Jan 1 00:00:00 1970 - Tue Jan 19 03:14:07 2038 (24855+03:14)
torvalds linux hobby Mon Aug 26 00:57:08 1991 gone - no logout
reboot system boot system-name Wed Aug 28 18:00:00 2013 still running
reboot system boot system-name Wed Aug 28 16:00:00 2013 - Wed Aug 28 17:00:00 2013 (01:00)
oldtime foo four Wed Aug 28 08:00:00 2013 - Wed Aug 28 09:00:00 2013 (01:00)
init foo five Wed Aug 28 07:00:00 2013 - Wed Aug 28 08:00:00 2013 (01:00)
login foo six Wed Aug 28 06:00:00 2013 - Wed Aug 28 07:00:00 2013 (01:00)
-user_pro foo seven Wed Aug 28 05:00:00 2013 - Wed Aug 28 06:00:00 2013 (01:00)
-accounti foo nine Wed Aug 28 03:00:00 2013 - Wed Aug 28 04:00:00 2013 (01:00)
+user_pr* foo seven Wed Aug 28 05:00:00 2013 - Wed Aug 28 06:00:00 2013 (01:00)
+account* foo nine Wed Aug 28 03:00:00 2013 - Wed Aug 28 04:00:00 2013 (01:00)
wtmp-a begins Wed Aug 28 03:00:00 2013
~~~ no time ~~~
-rick long never-gonna-logo (24855+03:14)
+rick long never-gonna-log* (24855+03:14)
torvalds linux hobby no logout
reboot system boot system-name running
reboot system boot system-name (01:00)
oldtime foo four (01:00)
init foo five (01:00)
login foo six (01:00)
-user_pro foo seven (01:00)
-accounti foo nine (01:00)
+user_pr* foo seven (01:00)
+account* foo nine (01:00)
~~~ iso-8601 time ~~~
rick long never-gonna-logout 1970-01-01T00:00:00+00:00 - 2038-01-19T03:14:07+00:00 (24855+03:14)
torvalds linux hobby 1991-08-26T00:57:08+00:00 gone - no logout
oldtime foo four Wed Aug 28 08:00 gone - no logout
init foo five Wed Aug 28 07:00 - 08:00 (01:00)
login foo six Wed Aug 28 06:00 - 07:00 (01:00)
-user_pro foo seven Wed Aug 28 05:00 - 06:00 (01:00)
-accounti foo nine Wed Aug 28 03:00 - 04:00 (01:00)
+user_pr* foo seven Wed Aug 28 05:00 - 06:00 (01:00)
+account* foo nine Wed Aug 28 03:00 - 04:00 (01:00)
wtmp-a begins Wed Aug 28 03:00:00 2013
~~~ present ~~~
-rick long never-gonna-logo Thu Jan 1 00:00 - 03:14 (24855+03:14)
+rick long never-gonna-log* Thu Jan 1 00:00 - 03:14 (24855+03:14)
torvalds linux hobby Mon Aug 26 00:57 gone - no logout
runlevel foo one Wed Aug 28 11:00 - 12:00 (01:00)