- Remove speed patch.
OBS-URL: https://build.opensuse.org/package/show/Base:System/less?expand=0&rev=28
This commit is contained in:
parent
3c57e29f9c
commit
9c1838f6d9
@ -1,191 +0,0 @@
|
||||
Index: cmdbuf.c
|
||||
===================================================================
|
||||
--- cmdbuf.c.orig
|
||||
+++ cmdbuf.c
|
||||
@@ -13,11 +13,16 @@
|
||||
* Used only by command() and related functions.
|
||||
*/
|
||||
|
||||
+#ifndef _GNU_SOURCE
|
||||
+#define _GNU_SOURCE
|
||||
+#endif
|
||||
#include "less.h"
|
||||
#include "cmd.h"
|
||||
#include "charset.h"
|
||||
#if HAVE_STAT
|
||||
+#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
extern int sc_width;
|
||||
@@ -1404,6 +1409,7 @@ init_cmdhist()
|
||||
#if CMD_HISTORY
|
||||
struct mlist *ml = NULL;
|
||||
char line[CMDBUF_SIZE];
|
||||
+ char buf[BUFSIZ];
|
||||
char *filename;
|
||||
FILE *f;
|
||||
char *p;
|
||||
@@ -1415,6 +1421,7 @@ init_cmdhist()
|
||||
free(filename);
|
||||
if (f == NULL)
|
||||
return;
|
||||
+ setbuf(f, buf);
|
||||
if (fgets(line, sizeof(line), f) == NULL ||
|
||||
strncmp(line, HISTFILE_FIRST_LINE, strlen(HISTFILE_FIRST_LINE)) != 0)
|
||||
{
|
||||
@@ -1489,8 +1496,16 @@ save_cmdhist()
|
||||
{
|
||||
#if CMD_HISTORY
|
||||
char *filename;
|
||||
+ char *tempname;
|
||||
+ char buf[BUFSIZ];
|
||||
FILE *f;
|
||||
- int modified = 0;
|
||||
+ int modified = 0, fd;
|
||||
+ mode_t umask_save;
|
||||
+#if HAVE_STAT
|
||||
+ struct stat st;
|
||||
+ uid_t uid;
|
||||
+ gid_t gid;
|
||||
+#endif
|
||||
|
||||
if (mlist_search.modified)
|
||||
modified = 1;
|
||||
@@ -1498,33 +1513,61 @@ save_cmdhist()
|
||||
if (mlist_shell.modified)
|
||||
modified = 1;
|
||||
#endif
|
||||
- if (!modified)
|
||||
+ if (!modified) {
|
||||
+ free(filename);
|
||||
return;
|
||||
- filename = histfile_name();
|
||||
- if (filename == NULL)
|
||||
+#if HAVE_STAT
|
||||
+ /* Do not overwrite other users history files due `su' */
|
||||
+ st.st_dev = st.st_ino = 0;
|
||||
+ st.st_mode = 0600;
|
||||
+ uid = getuid();
|
||||
+ gid = getgid();
|
||||
+ if ((stat(filename, &st) == 0) && (uid != 0) &&
|
||||
+ !((st.st_uid == uid) ? (st.st_mode & 0200)
|
||||
+ : ((st.st_gid == gid)
|
||||
+ ? (st.st_mode & 0020)
|
||||
+ : (st.st_mode & 0002))))
|
||||
+ {
|
||||
+ free(filename);
|
||||
return;
|
||||
- f = fopen(filename, "w");
|
||||
- free(filename);
|
||||
- if (f == NULL)
|
||||
+ }
|
||||
+
|
||||
+#endif
|
||||
+ tempname = malloc((strlen(filename)+strlen("XXXXXX"))*sizeof(char)+2);
|
||||
+ if (tempname == NULL) {
|
||||
+ free(filename);
|
||||
return;
|
||||
-#if HAVE_FCHMOD
|
||||
-{
|
||||
- /* Make history file readable only by owner. */
|
||||
- int do_chmod = 1;
|
||||
+ }
|
||||
+ sprintf(tempname, "%s.XXXXXX", filename);
|
||||
+ (void)mktemp(tempname);
|
||||
+ if (*tempname == '\0') {
|
||||
+ free(filename);
|
||||
+ free(tempname);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ umask_save = umask(077);
|
||||
#if HAVE_STAT
|
||||
- struct stat statbuf;
|
||||
- int r = fstat(fileno(f), &statbuf);
|
||||
- if (r < 0 || !S_ISREG(statbuf.st_mode))
|
||||
- /* Don't chmod if not a regular file. */
|
||||
- do_chmod = 0;
|
||||
-#endif
|
||||
- if (do_chmod)
|
||||
- fchmod(fileno(f), 0600);
|
||||
-}
|
||||
+ fd = open(tempname, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, ((st.st_mode & 0777) | 0600));
|
||||
+#else
|
||||
+ fd = open(tempname, O_CREAT|O_EXCL|O_WRONLY|O_NOFOLLOW, 0600));
|
||||
#endif
|
||||
+ (void)umask(umask_save);
|
||||
|
||||
+ if (fd < 0) {
|
||||
+ free(filename);
|
||||
+ free(tempname);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ f = fdopen(fd, "w");
|
||||
+ if (f == NULL) {
|
||||
+ free(filename);
|
||||
+ free(tempname);
|
||||
+ return;
|
||||
+ }
|
||||
+ setbuf(f, buf);
|
||||
fprintf(f, "%s\n", HISTFILE_FIRST_LINE);
|
||||
-
|
||||
fprintf(f, "%s\n", HISTFILE_SEARCH_SECTION);
|
||||
save_mlist(&mlist_search, f);
|
||||
|
||||
@@ -1534,5 +1577,10 @@ save_cmdhist()
|
||||
#endif
|
||||
|
||||
fclose(f);
|
||||
+
|
||||
+ if (rename(tempname, filename) < 0)
|
||||
+ unlink(tempname);
|
||||
+ free(filename);
|
||||
+ free(tempname);
|
||||
#endif /* CMD_HISTORY */
|
||||
}
|
||||
Index: configure.ac
|
||||
===================================================================
|
||||
--- configure.ac.orig
|
||||
+++ configure.ac
|
||||
@@ -253,7 +253,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
|
||||
|
||||
# Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
-AC_CHECK_FUNCS([fsync popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
|
||||
+AC_CHECK_FUNCS([tcdrain popen _setjmp sigprocmask sigsetmask snprintf stat system fchmod])
|
||||
|
||||
# AC_CHECK_FUNCS may not work for inline functions, so test these separately.
|
||||
AC_MSG_CHECKING(for memcpy)
|
||||
Index: screen.c
|
||||
===================================================================
|
||||
--- screen.c.orig
|
||||
+++ screen.c
|
||||
@@ -430,8 +430,8 @@ raw_mode(on)
|
||||
*/
|
||||
s = save_term;
|
||||
}
|
||||
-#if HAVE_FSYNC
|
||||
- fsync(tty);
|
||||
+#ifdef HAVE_TCDRAIN
|
||||
+ tcdrain(tty);
|
||||
#endif
|
||||
tcsetattr(tty, TCSADRAIN, &s);
|
||||
#if MUST_SET_LINE_DISCIPLINE
|
||||
Index: defines.h.in
|
||||
===================================================================
|
||||
--- defines.h.in.orig
|
||||
+++ defines.h.in
|
||||
@@ -222,8 +222,8 @@
|
||||
/* Define HAVE_FLOAT if your compiler supports the "double" type. */
|
||||
#undef HAVE_FLOAT
|
||||
|
||||
-/* Define to 1 if you have the `fsync' function. */
|
||||
-#undef HAVE_FSYNC
|
||||
+/* Define to 1 if you have the `tcdrain' function. */
|
||||
+#undef HAVE_TCDRAIN
|
||||
|
||||
/* GNU regex library */
|
||||
#undef HAVE_GNU_REGEX
|
@ -25,7 +25,7 @@ Tue Sep 25 07:48:44 UTC 2012 - vdziewiecki@suse.com
|
||||
|
||||
* Fix bug in displaying status column when scrolling
|
||||
* backwards with -J and -S in effect.
|
||||
- Comment out speed patch.
|
||||
- Remove speed patch.
|
||||
- Remove less-429-lessecho-man.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user