-/* $OpenBSD: history.c,v 1.45 2015/10/08 15:54:59 tedu Exp $ */
+/* $OpenBSD: history.c,v 1.46 2015/10/08 16:41:26 tedu Exp $ */
/*
* command history
unsigned char *base;
int lines;
int fd;
+ struct stat sb;
if (Flag(FTALKING) == 0)
return;
/* we have a file and are interactive */
if ((fd = open(hname, O_RDWR|O_CREAT|O_APPEND, 0600)) < 0)
return;
+ if (fstat(fd, &sb) == -1 || sb.st_uid != getuid()) {
+ close(fd);
+ return;
+ }
histfd = savefd(fd);
if (histfd != fd)
{
int fd;
char nfile[1024];
- struct stat statb;
unsigned char *nbase = oldbase;
int nbytes = oldbytes;
unlink(nfile);
return 1;
}
- /*
- * worry about who owns this file
- */
- if (fstat(histfd, &statb) >= 0)
- fchown(fd, statb.st_uid, statb.st_gid);
close(fd);
/*