/* Clone the file attributes from the existing file if there is one. */
if (!stat(drift_file,&buf)) {
- if (chown(temp_drift_file,buf.st_uid,buf.st_gid)) {
- LOG(LOGS_WARN, LOGF_Reference, "Could not change ownership of temporary driftfile %s.tmp", drift_file);
+ if (chown(temp_drift_file,buf.st_uid,buf.st_gid) ||
+ chmod(temp_drift_file,buf.st_mode & 0777)) {
+ LOG(LOGS_WARN, LOGF_Reference,
+ "Could not change ownership or permissions of temporary driftfile %s.tmp",
+ drift_file);
}
- chmod(temp_drift_file,buf.st_mode&0777);
}
/* Rename the temporary file to the correct location (see rename(2) for details). */
/* Clone the file attributes from the existing file if there is one. */
if (!stat(coefs_file_name,&buf)) {
- if (chown(temp_coefs_file_name,buf.st_uid,buf.st_gid)) {
- LOG(LOGS_WARN, LOGF_RtcLinux, "Could not change ownership of temporary RTC file %s.tmp", coefs_file_name);
+ if (chown(temp_coefs_file_name,buf.st_uid,buf.st_gid) ||
+ chmod(temp_coefs_file_name,buf.st_mode & 0777)) {
+ LOG(LOGS_WARN, LOGF_RtcLinux,
+ "Could not change ownership or permissions of temporary RTC file %s.tmp",
+ coefs_file_name);
}
- chmod(temp_coefs_file_name,buf.st_mode&0777);
}
/* Rename the temporary file to the correct location (see rename(2) for details). */
/* ================================================== */
-void
+int
UTI_FdSetCloexec(int fd)
{
int flags;
flags = fcntl(fd, F_GETFD);
if (flags != -1) {
flags |= FD_CLOEXEC;
- fcntl(fd, F_SETFD, flags);
+ return !fcntl(fd, F_SETFD, flags);
}
+
+ return 0;
}
/* ================================================== */
extern Float UTI_FloatHostToNetwork(double x);
/* Set FD_CLOEXEC on descriptor */
-extern void UTI_FdSetCloexec(int fd);
+extern int UTI_FdSetCloexec(int fd);
extern int UTI_GenerateNTPAuth(int hash_id, const unsigned char *key, int key_len,
const unsigned char *data, int data_len, unsigned char *auth, int auth_len);