52 lines
1 KiB
Text
52 lines
1 KiB
Text
$NetBSD: patch-ab,v 1.2 2005/03/16 20:10:56 rillig Exp $
|
|
|
|
--- record.c.orig Sat Nov 8 08:41:40 1997
|
|
+++ record.c Wed Mar 16 20:42:21 2005
|
|
@@ -14,6 +14,7 @@
|
|
#include<errno.h>
|
|
#include<ctype.h>
|
|
#include<pwd.h>
|
|
+#include<sys/stat.h>
|
|
|
|
#include"record.h"
|
|
|
|
@@ -182,13 +183,17 @@ static void error( void )
|
|
void init_record( void )
|
|
{
|
|
FILE *fp;
|
|
+ mode_t mask;
|
|
|
|
Record_entry = -1;
|
|
|
|
- if( ( fp = fopen( RECORD_FILE,"r+" ) ) == NULL ){
|
|
+ mask = umask(S_IWOTH);
|
|
+ if( ( fp = fopen( RECORD_FILE,"a+" ) ) == NULL ){
|
|
error();
|
|
return;
|
|
}
|
|
+ umask(mask);
|
|
+ rewind(fp);
|
|
flock( fileno(fp),LOCK_EX );
|
|
read_record( fp );
|
|
fclose( fp );
|
|
@@ -233,15 +238,18 @@ void save_record( int sc )
|
|
FILE *fp;
|
|
int i,r;
|
|
int uid;
|
|
+ mode_t mask;
|
|
|
|
if( Record_entry == -1 )
|
|
return ;
|
|
|
|
- if( (fp = fopen(RECORD_FILE,"r+")) == NULL ){
|
|
+ mask = umask(S_IWOTH);
|
|
+ if( (fp = fopen(RECORD_FILE,"a+")) == NULL ){
|
|
error();
|
|
return;
|
|
}
|
|
-
|
|
+ umask(mask);
|
|
+ rewind(fp);
|
|
flock( fileno(fp),LOCK_EX );
|
|
read_record( fp );
|
|
|