Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars
*** 29,38 ****
--- 29,40 ----
* Use is subject to license terms.
*/
/*
* Copyright 2012 Joyent, Inc. All rights reserved.
+ *
+ * Copyright (c) 2013 Gary Mills
*/
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
*** 58,79 ****
#include <sys/contract/process.h>
#include <libcontract.h>
#include <sys/ctfs.h>
/*
! * utmpx defines wider fields for user and line. For compatibility of output,
! * we are limiting these to the old maximums in utmp. Define UTMPX_NAMELEN
! * to use the full lengths.
*/
! #ifndef UTMPX_NAMELEN
! /* XXX - utmp -fix name length */
! #define NMAX (_POSIX_LOGIN_NAME_MAX - 1)
! #define LMAX 12
! #else /* UTMPX_NAMELEN */
! #define NMAX (sizeof (((struct utmpx *)0)->ut_user)
! #define LMAX (sizeof (((struct utmpx *)0)->ut_line)
! #endif /* UTMPX_NAMELEN */
static char mesg[3000];
static char *infile;
static int gflag;
static struct group *pgrp;
--- 60,73 ----
#include <sys/contract/process.h>
#include <libcontract.h>
#include <sys/ctfs.h>
/*
! * Use the full lengths from utmpx for user and line.
*/
! #define NMAX (sizeof (((struct utmpx *)0)->ut_user))
! #define LMAX (sizeof (((struct utmpx *)0)->ut_line))
static char mesg[3000];
static char *infile;
static int gflag;
static struct group *pgrp;
*** 80,90 ****
static char *grpname;
static char line[MAXNAMLEN+1] = "???";
static char systm[MAXNAMLEN+1];
static time_t tloc;
static struct utsname utsn;
! static char who[9] = "???";
static char time_buf[50];
#define DATE_FMT "%a %b %e %H:%M:%S"
static void sendmes(struct utmpx *, zoneid_t);
static void sendmes_tozone(zoneid_t, int);
--- 74,84 ----
static char *grpname;
static char line[MAXNAMLEN+1] = "???";
static char systm[MAXNAMLEN+1];
static time_t tloc;
static struct utsname utsn;
! static char who[NMAX+1] = "???";
static char time_buf[50];
#define DATE_FMT "%a %b %e %H:%M:%S"
static void sendmes(struct utmpx *, zoneid_t);
static void sendmes_tozone(zoneid_t, int);
*** 224,234 ****
if (rwho[0] != '\0') {
cp = copy_str_till(rsystm, ++cp, ':',
MAXNAMLEN + 1);
if (rsystm[0] != '\0') {
(void) strcpy(systm, rsystm);
! (void) strncpy(rwho, who, 9);
(void) strcpy(line, "rpc.rwalld");
}
}
}
}
--- 218,229 ----
if (rwho[0] != '\0') {
cp = copy_str_till(rsystm, ++cp, ':',
MAXNAMLEN + 1);
if (rsystm[0] != '\0') {
(void) strcpy(systm, rsystm);
! (void) strncpy(rwho, who,
! sizeof (who));
(void) strcpy(line, "rpc.rwalld");
}
}
}
}
*** 426,436 ****
who, line, systm, time_buf);
if (gflag)
(void) fprintf(f, " to group %s", grpname);
(void) fprintf(f, "...\n");
#ifdef DEBUG
! (void) fprintf(f, "DEBUG: To %.8s on %s\n", p->ut_user, s);
#endif
i = strlen(mesg);
for (bp = mesg; --i >= 0; bp++) {
ibp = (unsigned int)((unsigned char) *bp);
if (*bp == '\n')
--- 421,431 ----
who, line, systm, time_buf);
if (gflag)
(void) fprintf(f, " to group %s", grpname);
(void) fprintf(f, "...\n");
#ifdef DEBUG
! (void) fprintf(f, "DEBUG: To %.*s on %s\n", NMAX, p->ut_user, s);
#endif
i = strlen(mesg);
for (bp = mesg; --i >= 0; bp++) {
ibp = (unsigned int)((unsigned char) *bp);
if (*bp == '\n')
*** 468,484 ****
static int
chkgrp(char *name)
{
int i;
! char *p;
for (i = 0; pgrp->gr_mem[i] && pgrp->gr_mem[i][0]; i++) {
! for (p = name; *p && *p != ' '; p++)
! ;
! *p = 0;
! if (strncmp(name, pgrp->gr_mem[i], 8) == 0)
return (1);
}
return (0);
}
--- 463,477 ----
static int
chkgrp(char *name)
{
int i;
! char user[NMAX + 1];
+ (void) strlcpy(user, name, sizeof (user));
for (i = 0; pgrp->gr_mem[i] && pgrp->gr_mem[i][0]; i++) {
! if (strcmp(user, pgrp->gr_mem[i]) == 0)
return (1);
}
return (0);
}