Copy from Base:System/termcap based on submit request 23248 from user WernerFink OBS-URL: https://build.opensuse.org/request/show/23248 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/termcap?expand=0&rev=6
61 lines
1.3 KiB
Diff
61 lines
1.3 KiB
Diff
Index: termcap-2.0.8/termcap.c
|
|
===================================================================
|
|
--- termcap-2.0.8.orig/termcap.c
|
|
+++ termcap-2.0.8/termcap.c
|
|
@@ -21,6 +21,7 @@
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <malloc.h>
|
|
+#include <sys/fsuid.h>
|
|
#include <string.h>
|
|
#include <sys/ioctl.h>
|
|
#include <termios.h>
|
|
@@ -342,13 +343,17 @@ static char *tc_read(struct tc_ent **tcp
|
|
struct tc_ent *l = NULL;
|
|
int first = 1;
|
|
int loop = 0;
|
|
+ int tc_set = 0;
|
|
|
|
*tcp = NULL;
|
|
|
|
/* See if we have a TERMCAP environment variable. */
|
|
if ((tc = getenv("TERMCAP")) != NULL) {
|
|
if (*tc == '/')
|
|
+ {
|
|
tc_file = tc;
|
|
+ tc_set=1;
|
|
+ }
|
|
else {
|
|
/* check if TERMCAP is term */
|
|
if (tc_comp(tc, term)) {
|
|
@@ -369,8 +374,28 @@ static char *tc_read(struct tc_ent **tcp
|
|
printf("Using file %s\n", tc_file);
|
|
#endif
|
|
|
|
+ if(tc_set)
|
|
+ {
|
|
+ if (-1 == setfsuid(getuid())) {
|
|
+ perror("setfsuid");
|
|
+ return NULL;
|
|
+ }
|
|
+ if (-1 == setfsgid(getgid())) {
|
|
+ setfsuid(geteuid());
|
|
+ perror("setfsgid");
|
|
+ return NULL;
|
|
+ }
|
|
+ }
|
|
/* Now read the termcap file. */
|
|
- if ((fp = fopen(tc_file, "r")) == NULL) return(NULL);
|
|
+ fp = fopen(tc_file, "r");
|
|
+
|
|
+ if(tc_set)
|
|
+ {
|
|
+ setfsuid(geteuid());
|
|
+ setfsgid(getegid());
|
|
+ }
|
|
+ if (fp == NULL)
|
|
+ return(NULL);
|
|
|
|
while(term) {
|
|
if (++loop > 16) {
|