OBS User unknown 2007-12-12 17:18:44 +00:00 committed by Git OBS Bridge
parent 32ef673f9d
commit 411f554a30
3 changed files with 120 additions and 2 deletions

View File

@ -0,0 +1,106 @@
--- sysctl.c
+++ sysctl.c 2007-12-12 12:05:48.138322148 +0100
@@ -128,6 +128,7 @@ static int ReadSetting(const char *restr
char *restrict outname;
char inbuf[1025];
FILE *restrict fp;
+ struct stat ts;
if (!name || !*name) {
fprintf(stderr, ERR_INVALID_KEY, name);
@@ -135,7 +136,7 @@ static int ReadSetting(const char *restr
}
/* used to open the file */
- tmpname = malloc(strlen(name)+strlen(PROC_PATH)+1);
+ tmpname = malloc(strlen(name)+strlen(PROC_PATH)+2);
strcpy(tmpname, PROC_PATH);
strcat(tmpname, name);
slashdot(tmpname+strlen(PROC_PATH),'.','/'); /* change . to / */
@@ -144,6 +145,23 @@ static int ReadSetting(const char *restr
outname = strdup(name);
slashdot(outname,'/','.'); /* change / to . */
+ if (stat(tmpname, &ts) < 0) {
+ perror(tmpname);
+ rc = -1;
+ goto out;
+ }
+ if ((ts.st_mode & S_IRUSR) == 0)
+ goto out;
+
+ if (S_ISDIR(ts.st_mode)) {
+ size_t len;
+ len = strlen(tmpname);
+ tmpname[len] = '/';
+ tmpname[len+1] = '\0';
+ rc = DisplayAll(tmpname);
+ goto out;
+ }
+
fp = fopen(tmpname, "r");
if (!fp) {
@@ -194,8 +212,9 @@ static int ReadSetting(const char *restr
len = strlen(tmpname);
tmpname[len] = '/';
tmpname[len+1] = '\0';
+ fclose(fp);
rc = DisplayAll(tmpname);
- break;
+ goto out;
}
default:
fprintf(stderr, ERR_UNKNOWN_READING, strerror(errno), outname);
@@ -205,7 +224,7 @@ static int ReadSetting(const char *restr
}
fclose(fp);
}
-
+out:
free(tmpname);
free(outname);
return rc;
@@ -265,8 +284,9 @@ static int WriteSetting(const char *sett
const char *value;
const char *equals;
char *tmpname;
- FILE *fp;
char *outname;
+ FILE *fp;
+ struct stat ts;
if (!name) { /* probably don't want to display this err */
return 0;
@@ -299,6 +319,22 @@ static int WriteSetting(const char *sett
outname[equals-name] = 0;
slashdot(outname,'/','.'); /* change / to . */
+ if (stat(tmpname, &ts) < 0) {
+ perror(tmpname);
+ rc = -1;
+ goto out;
+ }
+
+ if ((ts.st_mode & S_IWUSR) == 0) {
+ fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(EACCES), outname);
+ goto out;
+ }
+
+ if (S_ISDIR(ts.st_mode)) {
+ fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(EACCES), outname);
+ goto out;
+ }
+
fp = fopen(tmpname, "w");
if (!fp) {
@@ -343,7 +379,7 @@ static int WriteSetting(const char *sett
}
}
}
-
+out:
free(tmpname);
free(outname);
return rc;

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Dec 12 12:11:39 CET 2007 - werner@suse.de
- Add workaround for change in glibc 2.6.1 which is that a dir can
not be opened with both open(2) and opendir(2) (bug #347322)
-------------------------------------------------------------------
Fri Oct 26 10:47:06 CEST 2007 - jdelvare@suse.de

View File

@ -13,12 +13,12 @@
Name: procps
BuildRequires: ncurses-devel
Url: http://procps.sf.net
License: GPL v2 or later; LGPL v2 or later
License: GPL v2 or later; LGPL v2.1 or later
Group: System/Monitoring
PreReq: %fillup_prereq %insserv_prereq
AutoReqProv: on
Version: 3.2.7
Release: 70
Release: 79
Summary: ps utilities for /proc
Provides: ps
Obsoletes: ps
@ -44,6 +44,7 @@ Patch16: procps-3.2.7-cpu_hotplug.patch
Patch17: procps-3.2.5-CPU-states.patch
Patch18: procps-3.2.7-readeof.patch
Patch19: procps-3.2.7-btime-from-proc-stat.patch
Patch20: procps-3.2.7-glibc-2.6.1.dif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -91,6 +92,7 @@ Authors:
%patch17
%patch18
%patch19 -p1
%patch20
%build
make CFLAGS="-Wall -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $RPM_OPT_FLAGS -pipe" \
@ -154,7 +156,11 @@ rm -rf $RPM_BUILD_ROOT
%_mandir/man5/sysctl.conf.5.gz
%_mandir/man8/vmstat.8.gz
%_mandir/man8/sysctl.8.gz
%changelog
* Wed Dec 12 2007 - werner@suse.de
- Add workaround for change in glibc 2.6.1 which is that a dir can
not be opened with both open(2) and opendir(2) (bug #347322)
* Fri Oct 26 2007 - jdelvare@suse.de
- Read the time of system boot from /proc/stat (entry: btime)
instead of computing it as the difference between the current