Mercurial > dropbear
comparison loginrec.c @ 1323:83d85b28b353
upgrade atomicio
in order to remove K&R code in atomicio.c
now, vwrite comes from atomicio.h
author | Francois Perrad <francois.perrad@gadz.org> |
---|---|
date | Fri, 25 Mar 2016 12:05:17 +0100 |
parents | 1ed6f39e8aa4 |
children | c7675aa88880 |
comparison
equal
deleted
inserted
replaced
1322:826a3293fe5a | 1323:83d85b28b353 |
---|---|
704 (strncmp(old_ut.ut_name, ut->ut_name, sizeof(ut->ut_name)) == 0)) { | 704 (strncmp(old_ut.ut_name, ut->ut_name, sizeof(ut->ut_name)) == 0)) { |
705 (void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host)); | 705 (void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host)); |
706 } | 706 } |
707 | 707 |
708 (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); | 708 (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); |
709 if (atomicio(write, fd, ut, sizeof(*ut)) != sizeof(*ut)) | 709 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) |
710 dropbear_log(LOG_WARNING, "utmp_write_direct: error writing %s: %s", | 710 dropbear_log(LOG_WARNING, "utmp_write_direct: error writing %s: %s", |
711 UTMP_FILE, strerror(errno)); | 711 UTMP_FILE, strerror(errno)); |
712 | 712 |
713 (void)close(fd); | 713 (void)close(fd); |
714 return 1; | 714 return 1; |
893 dropbear_log(LOG_WARNING, "wtmp_write: problem writing %s: %s", | 893 dropbear_log(LOG_WARNING, "wtmp_write: problem writing %s: %s", |
894 WTMP_FILE, strerror(errno)); | 894 WTMP_FILE, strerror(errno)); |
895 return 0; | 895 return 0; |
896 } | 896 } |
897 if (fstat(fd, &buf) == 0) | 897 if (fstat(fd, &buf) == 0) |
898 if (atomicio(write, fd, ut, sizeof(*ut)) != sizeof(*ut)) { | 898 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) { |
899 ftruncate(fd, buf.st_size); | 899 ftruncate(fd, buf.st_size); |
900 dropbear_log(LOG_WARNING, "wtmp_write: problem writing %s: %s", | 900 dropbear_log(LOG_WARNING, "wtmp_write: problem writing %s: %s", |
901 WTMP_FILE, strerror(errno)); | 901 WTMP_FILE, strerror(errno)); |
902 ret = 0; | 902 ret = 0; |
903 } | 903 } |
1060 WTMPX_FILE, strerror(errno)); | 1060 WTMPX_FILE, strerror(errno)); |
1061 return 0; | 1061 return 0; |
1062 } | 1062 } |
1063 | 1063 |
1064 if (fstat(fd, &buf) == 0) | 1064 if (fstat(fd, &buf) == 0) |
1065 if (atomicio(write, fd, utx, sizeof(*utx)) != sizeof(*utx)) { | 1065 if (atomicio(vwrite, fd, utx, sizeof(*utx)) != sizeof(*utx)) { |
1066 ftruncate(fd, buf.st_size); | 1066 ftruncate(fd, buf.st_size); |
1067 dropbear_log(LOG_WARNING, "wtmpx_write: problem writing %s: %s", | 1067 dropbear_log(LOG_WARNING, "wtmpx_write: problem writing %s: %s", |
1068 WTMPX_FILE, strerror(errno)); | 1068 WTMPX_FILE, strerror(errno)); |
1069 ret = 0; | 1069 ret = 0; |
1070 } | 1070 } |
1349 | 1349 |
1350 if (!lastlog_openseek(li, &fd, O_RDWR|O_CREAT)) | 1350 if (!lastlog_openseek(li, &fd, O_RDWR|O_CREAT)) |
1351 return(0); | 1351 return(0); |
1352 | 1352 |
1353 /* write the entry */ | 1353 /* write the entry */ |
1354 if (atomicio(write, fd, &last, sizeof(last)) != sizeof(last)) { | 1354 if (atomicio(vwrite, fd, &last, sizeof(last)) != sizeof(last)) { |
1355 close(fd); | 1355 close(fd); |
1356 dropbear_log(LOG_WARNING, "lastlog_write_filemode: Error writing to %s: %s", | 1356 dropbear_log(LOG_WARNING, "lastlog_write_filemode: Error writing to %s: %s", |
1357 LASTLOG_FILE, strerror(errno)); | 1357 LASTLOG_FILE, strerror(errno)); |
1358 return 0; | 1358 return 0; |
1359 } | 1359 } |