summaryrefslogtreecommitdiff
path: root/loginrec.c
diff options
context:
space:
mode:
Diffstat (limited to 'loginrec.c')
-rw-r--r--loginrec.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/loginrec.c b/loginrec.c
index 8d48fb99f..e6b70f58c 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -140,7 +140,7 @@
140# include <libutil.h> 140# include <libutil.h>
141#endif 141#endif
142 142
143RCSID("$Id: loginrec.c,v 1.60 2004/09/12 05:18:55 djm Exp $"); 143RCSID("$Id: loginrec.c,v 1.61 2004/09/12 05:25:17 djm Exp $");
144 144
145/** 145/**
146 ** prototypes for helper functions in this file 146 ** prototypes for helper functions in this file
@@ -266,7 +266,7 @@ login_get_lastlog(struct logininfo *li, const int uid)
266 */ 266 */
267 pw = getpwuid(uid); 267 pw = getpwuid(uid);
268 if (pw == NULL) 268 if (pw == NULL)
269 fatal("login_get_lastlog: Cannot find account for uid %i", uid); 269 fatal("%s: Cannot find account for uid %i", __func__, uid);
270 270
271 /* No MIN_SIZEOF here - we absolutely *must not* truncate the 271 /* No MIN_SIZEOF here - we absolutely *must not* truncate the
272 * username (XXX - so check for trunc!) */ 272 * username (XXX - so check for trunc!) */
@@ -335,7 +335,7 @@ login_init_entry(struct logininfo *li, int pid, const char *username,
335 strlcpy(li->username, username, sizeof(li->username)); 335 strlcpy(li->username, username, sizeof(li->username));
336 pw = getpwnam(li->username); 336 pw = getpwnam(li->username);
337 if (pw == NULL) { 337 if (pw == NULL) {
338 fatal("login_init_entry: Cannot find user \"%s\"", 338 fatal("%s: Cannot find user \"%s\"", __func__,
339 li->username); 339 li->username);
340 } 340 }
341 li->uid = pw->pw_uid; 341 li->uid = pw->pw_uid;
@@ -864,12 +864,12 @@ utmp_perform_login(struct logininfo *li)
864 construct_utmp(li, &ut); 864 construct_utmp(li, &ut);
865# ifdef UTMP_USE_LIBRARY 865# ifdef UTMP_USE_LIBRARY
866 if (!utmp_write_library(li, &ut)) { 866 if (!utmp_write_library(li, &ut)) {
867 logit("utmp_perform_login: utmp_write_library() failed"); 867 logit("%s: utmp_write_library() failed", __func__);
868 return (0); 868 return (0);
869 } 869 }
870# else 870# else
871 if (!utmp_write_direct(li, &ut)) { 871 if (!utmp_write_direct(li, &ut)) {
872 logit("utmp_perform_login: utmp_write_direct() failed"); 872 logit("%s: utmp_write_direct() failed", __func__);
873 return (0); 873 return (0);
874 } 874 }
875# endif 875# endif
@@ -885,12 +885,12 @@ utmp_perform_logout(struct logininfo *li)
885 construct_utmp(li, &ut); 885 construct_utmp(li, &ut);
886# ifdef UTMP_USE_LIBRARY 886# ifdef UTMP_USE_LIBRARY
887 if (!utmp_write_library(li, &ut)) { 887 if (!utmp_write_library(li, &ut)) {
888 logit("utmp_perform_logout: utmp_write_library() failed"); 888 logit("%s: utmp_write_library() failed", __func__);
889 return (0); 889 return (0);
890 } 890 }
891# else 891# else
892 if (!utmp_write_direct(li, &ut)) { 892 if (!utmp_write_direct(li, &ut)) {
893 logit("utmp_perform_logout: utmp_write_direct() failed"); 893 logit("%s: utmp_write_direct() failed", __func__);
894 return (0); 894 return (0);
895 } 895 }
896# endif 896# endif
@@ -909,7 +909,7 @@ utmp_write_entry(struct logininfo *li)
909 return (utmp_perform_logout(li)); 909 return (utmp_perform_logout(li));
910 910
911 default: 911 default:
912 logit("utmp_write_entry: invalid type field"); 912 logit("%s: invalid type field", __func__);
913 return (0); 913 return (0);
914 } 914 }
915} 915}
@@ -950,7 +950,7 @@ utmpx_write_library(struct logininfo *li, struct utmpx *utx)
950static int 950static int
951utmpx_write_direct(struct logininfo *li, struct utmpx *utx) 951utmpx_write_direct(struct logininfo *li, struct utmpx *utx)
952{ 952{
953 logit("utmpx_write_direct: not implemented!"); 953 logit("%s: not implemented!", __func__);
954 return (0); 954 return (0);
955} 955}
956# endif /* UTMPX_USE_LIBRARY */ 956# endif /* UTMPX_USE_LIBRARY */
@@ -963,12 +963,12 @@ utmpx_perform_login(struct logininfo *li)
963 construct_utmpx(li, &utx); 963 construct_utmpx(li, &utx);
964# ifdef UTMPX_USE_LIBRARY 964# ifdef UTMPX_USE_LIBRARY
965 if (!utmpx_write_library(li, &utx)) { 965 if (!utmpx_write_library(li, &utx)) {
966 logit("utmpx_perform_login: utmp_write_library() failed"); 966 logit("%s: utmp_write_library() failed", __func__);
967 return (0); 967 return (0);
968 } 968 }
969# else 969# else
970 if (!utmpx_write_direct(li, &ut)) { 970 if (!utmpx_write_direct(li, &ut)) {
971 logit("utmpx_perform_login: utmp_write_direct() failed"); 971 logit("%s: utmp_write_direct() failed", __func__);
972 return (0); 972 return (0);
973 } 973 }
974# endif 974# endif
@@ -1006,7 +1006,7 @@ utmpx_write_entry(struct logininfo *li)
1006 case LTYPE_LOGOUT: 1006 case LTYPE_LOGOUT:
1007 return (utmpx_perform_logout(li)); 1007 return (utmpx_perform_logout(li));
1008 default: 1008 default:
1009 logit("utmpx_write_entry: invalid type field"); 1009 logit("%s: invalid type field", __func__);
1010 return (0); 1010 return (0);
1011 } 1011 }
1012} 1012}
@@ -1030,14 +1030,14 @@ wtmp_write(struct logininfo *li, struct utmp *ut)
1030 int fd, ret = 1; 1030 int fd, ret = 1;
1031 1031
1032 if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) { 1032 if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
1033 logit("wtmp_write: problem writing %s: %s", 1033 logit("%s: problem writing %s: %s", __func__,
1034 WTMP_FILE, strerror(errno)); 1034 WTMP_FILE, strerror(errno));
1035 return (0); 1035 return (0);
1036 } 1036 }
1037 if (fstat(fd, &buf) == 0) 1037 if (fstat(fd, &buf) == 0)
1038 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) { 1038 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) {
1039 ftruncate(fd, buf.st_size); 1039 ftruncate(fd, buf.st_size);
1040 logit("wtmp_write: problem writing %s: %s", 1040 logit("%s: problem writing %s: %s", __func__,
1041 WTMP_FILE, strerror(errno)); 1041 WTMP_FILE, strerror(errno));
1042 ret = 0; 1042 ret = 0;
1043 } 1043 }
@@ -1074,7 +1074,7 @@ wtmp_write_entry(struct logininfo *li)
1074 case LTYPE_LOGOUT: 1074 case LTYPE_LOGOUT:
1075 return (wtmp_perform_logout(li)); 1075 return (wtmp_perform_logout(li));
1076 default: 1076 default:
1077 logit("wtmp_write_entry: invalid type field"); 1077 logit("%s: invalid type field", __func__);
1078 return (0); 1078 return (0);
1079 } 1079 }
1080} 1080}
@@ -1124,12 +1124,12 @@ wtmp_get_entry(struct logininfo *li)
1124 li->tv_sec = li->tv_usec = 0; 1124 li->tv_sec = li->tv_usec = 0;
1125 1125
1126 if ((fd = open(WTMP_FILE, O_RDONLY)) < 0) { 1126 if ((fd = open(WTMP_FILE, O_RDONLY)) < 0) {
1127 logit("wtmp_get_entry: problem opening %s: %s", 1127 logit("%s: problem opening %s: %s", __func__,
1128 WTMP_FILE, strerror(errno)); 1128 WTMP_FILE, strerror(errno));
1129 return (0); 1129 return (0);
1130 } 1130 }
1131 if (fstat(fd, &st) != 0) { 1131 if (fstat(fd, &st) != 0) {
1132 logit("wtmp_get_entry: couldn't stat %s: %s", 1132 logit("%s: couldn't stat %s: %s", __func__,
1133 WTMP_FILE, strerror(errno)); 1133 WTMP_FILE, strerror(errno));
1134 close(fd); 1134 close(fd);
1135 return (0); 1135 return (0);
@@ -1144,7 +1144,7 @@ wtmp_get_entry(struct logininfo *li)
1144 1144
1145 while (!found) { 1145 while (!found) {
1146 if (atomicio(read, fd, &ut, sizeof(ut)) != sizeof(ut)) { 1146 if (atomicio(read, fd, &ut, sizeof(ut)) != sizeof(ut)) {
1147 logit("wtmp_get_entry: read of %s failed: %s", 1147 logit("%s: read of %s failed: %s", __func__,
1148 WTMP_FILE, strerror(errno)); 1148 WTMP_FILE, strerror(errno));
1149 close (fd); 1149 close (fd);
1150 return (0); 1150 return (0);
@@ -1202,7 +1202,7 @@ wtmpx_write(struct logininfo *li, struct utmpx *utx)
1202 int fd, ret = 1; 1202 int fd, ret = 1;
1203 1203
1204 if ((fd = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) { 1204 if ((fd = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) {
1205 logit("wtmpx_write: problem opening %s: %s", 1205 logit("%s: problem opening %s: %s", __func__,
1206 WTMPX_FILE, strerror(errno)); 1206 WTMPX_FILE, strerror(errno));
1207 return (0); 1207 return (0);
1208 } 1208 }
@@ -1210,7 +1210,7 @@ wtmpx_write(struct logininfo *li, struct utmpx *utx)
1210 if (fstat(fd, &buf) == 0) 1210 if (fstat(fd, &buf) == 0)
1211 if (atomicio(vwrite, fd, utx, sizeof(*utx)) != sizeof(*utx)) { 1211 if (atomicio(vwrite, fd, utx, sizeof(*utx)) != sizeof(*utx)) {
1212 ftruncate(fd, buf.st_size); 1212 ftruncate(fd, buf.st_size);
1213 logit("wtmpx_write: problem writing %s: %s", 1213 logit("%s: problem writing %s: %s", __func__,
1214 WTMPX_FILE, strerror(errno)); 1214 WTMPX_FILE, strerror(errno));
1215 ret = 0; 1215 ret = 0;
1216 } 1216 }
@@ -1253,7 +1253,7 @@ wtmpx_write_entry(struct logininfo *li)
1253 case LTYPE_LOGOUT: 1253 case LTYPE_LOGOUT:
1254 return (wtmpx_perform_logout(li)); 1254 return (wtmpx_perform_logout(li));
1255 default: 1255 default:
1256 logit("wtmpx_write_entry: invalid type field"); 1256 logit("%s: invalid type field", __func__);
1257 return (0); 1257 return (0);
1258 } 1258 }
1259} 1259}
@@ -1289,12 +1289,12 @@ wtmpx_get_entry(struct logininfo *li)
1289 li->tv_sec = li->tv_usec = 0; 1289 li->tv_sec = li->tv_usec = 0;
1290 1290
1291 if ((fd = open(WTMPX_FILE, O_RDONLY)) < 0) { 1291 if ((fd = open(WTMPX_FILE, O_RDONLY)) < 0) {
1292 logit("wtmpx_get_entry: problem opening %s: %s", 1292 logit("%s: problem opening %s: %s", __func__,
1293 WTMPX_FILE, strerror(errno)); 1293 WTMPX_FILE, strerror(errno));
1294 return (0); 1294 return (0);
1295 } 1295 }
1296 if (fstat(fd, &st) != 0) { 1296 if (fstat(fd, &st) != 0) {
1297 logit("wtmpx_get_entry: couldn't stat %s: %s", 1297 logit("%s: couldn't stat %s: %s", __func__,
1298 WTMPX_FILE, strerror(errno)); 1298 WTMPX_FILE, strerror(errno));
1299 close(fd); 1299 close(fd);
1300 return (0); 1300 return (0);
@@ -1309,7 +1309,7 @@ wtmpx_get_entry(struct logininfo *li)
1309 1309
1310 while (!found) { 1310 while (!found) {
1311 if (atomicio(read, fd, &utx, sizeof(utx)) != sizeof(utx)) { 1311 if (atomicio(read, fd, &utx, sizeof(utx)) != sizeof(utx)) {
1312 logit("wtmpx_get_entry: read of %s failed: %s", 1312 logit("%s: read of %s failed: %s", __func__,
1313 WTMPX_FILE, strerror(errno)); 1313 WTMPX_FILE, strerror(errno));
1314 close (fd); 1314 close (fd);
1315 return (0); 1315 return (0);
@@ -1354,7 +1354,7 @@ syslogin_perform_login(struct logininfo *li)
1354 struct utmp *ut; 1354 struct utmp *ut;
1355 1355
1356 if ((ut = (struct utmp *)malloc(sizeof(*ut))) == NULL) { 1356 if ((ut = (struct utmp *)malloc(sizeof(*ut))) == NULL) {
1357 logit("syslogin_perform_login: couldn't malloc()"); 1357 logit("%s: couldn't malloc()", __func__);
1358 return (0); 1358 return (0);
1359 } 1359 }
1360 construct_utmp(li, ut); 1360 construct_utmp(li, ut);
@@ -1373,7 +1373,7 @@ syslogin_perform_logout(struct logininfo *li)
1373 (void)line_stripname(line, li->line, sizeof(line)); 1373 (void)line_stripname(line, li->line, sizeof(line));
1374 1374
1375 if (!logout(line)) 1375 if (!logout(line))
1376 logit("syslogin_perform_logout: logout() returned an error"); 1376 logit("%s: logout() returned an error", __func__);
1377# ifdef HAVE_LOGWTMP 1377# ifdef HAVE_LOGWTMP
1378 else 1378 else
1379 logwtmp(line, "", ""); 1379 logwtmp(line, "", "");
@@ -1395,7 +1395,7 @@ syslogin_write_entry(struct logininfo *li)
1395 case LTYPE_LOGOUT: 1395 case LTYPE_LOGOUT:
1396 return (syslogin_perform_logout(li)); 1396 return (syslogin_perform_logout(li));
1397 default: 1397 default:
1398 logit("syslogin_write_entry: Invalid type field"); 1398 logit("%s: Invalid type field", __func__);
1399 return (0); 1399 return (0);
1400 } 1400 }
1401} 1401}
@@ -1430,7 +1430,7 @@ lastlog_filetype(char *filename)
1430 struct stat st; 1430 struct stat st;
1431 1431
1432 if (stat(LASTLOG_FILE, &st) != 0) { 1432 if (stat(LASTLOG_FILE, &st) != 0) {
1433 logit("lastlog_perform_login: Couldn't stat %s: %s", 1433 logit("%s: Couldn't stat %s: %s", __func__,
1434 LASTLOG_FILE, strerror(errno)); 1434 LASTLOG_FILE, strerror(errno));
1435 return (0); 1435 return (0);
1436 } 1436 }
@@ -1462,14 +1462,14 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
1462 LASTLOG_FILE, li->username); 1462 LASTLOG_FILE, li->username);
1463 break; 1463 break;
1464 default: 1464 default:
1465 logit("lastlog_openseek: %.100s is not a file or directory!", 1465 logit("%s: %.100s is not a file or directory!", __func__,
1466 LASTLOG_FILE); 1466 LASTLOG_FILE);
1467 return (0); 1467 return (0);
1468 } 1468 }
1469 1469
1470 *fd = open(lastlog_file, filemode, 0600); 1470 *fd = open(lastlog_file, filemode, 0600);
1471 if (*fd < 0) { 1471 if (*fd < 0) {
1472 debug("lastlog_openseek: Couldn't open %s: %s", 1472 debug("%s: Couldn't open %s: %s", __func__,
1473 lastlog_file, strerror(errno)); 1473 lastlog_file, strerror(errno));
1474 return (0); 1474 return (0);
1475 } 1475 }
@@ -1479,8 +1479,8 @@ lastlog_openseek(struct logininfo *li, int *fd, int filemode)
1479 offset = (off_t) ((long)li->uid * sizeof(struct lastlog)); 1479 offset = (off_t) ((long)li->uid * sizeof(struct lastlog));
1480 1480
1481 if (lseek(*fd, offset, SEEK_SET) != offset) { 1481 if (lseek(*fd, offset, SEEK_SET) != offset) {
1482 logit("lastlog_openseek: %s->lseek(): %s", 1482 logit("%s: %s->lseek(): %s", __func__,
1483 lastlog_file, strerror(errno)); 1483 lastlog_file, strerror(errno));
1484 return (0); 1484 return (0);
1485 } 1485 }
1486 } 1486 }
@@ -1503,7 +1503,7 @@ lastlog_perform_login(struct logininfo *li)
1503 /* write the entry */ 1503 /* write the entry */
1504 if (atomicio(vwrite, fd, &last, sizeof(last)) != sizeof(last)) { 1504 if (atomicio(vwrite, fd, &last, sizeof(last)) != sizeof(last)) {
1505 close(fd); 1505 close(fd);
1506 logit("lastlog_write_filemode: Error writing to %s: %s", 1506 logit("%s: Error writing to %s: %s", __func__,
1507 LASTLOG_FILE, strerror(errno)); 1507 LASTLOG_FILE, strerror(errno));
1508 return (0); 1508 return (0);
1509 } 1509 }
@@ -1519,7 +1519,7 @@ lastlog_write_entry(struct logininfo *li)
1519 case LTYPE_LOGIN: 1519 case LTYPE_LOGIN:
1520 return (lastlog_perform_login(li)); 1520 return (lastlog_perform_login(li));
1521 default: 1521 default:
1522 logit("lastlog_write_entry: Invalid type field"); 1522 logit("%s: Invalid type field", __func__);
1523 return (0); 1523 return (0);
1524 } 1524 }
1525} 1525}