Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1494730
 поиск   регистрация   авторизация 
 
Группа :: Графические оболочки/KDE
Пакет: kdenetwork

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: kdenetwork-3.1.4-lisa_drop_privileges.patch


diff -uNr kdenetwork-3.1.4~/lanbrowsing/lisa/main.cpp kdenetwork-3.1.4/lanbrowsing/lisa/main.cpp
--- kdenetwork-3.1.4~/lanbrowsing/lisa/main.cpp	2003-05-21 16:24:22 +0400
+++ kdenetwork-3.1.4/lanbrowsing/lisa/main.cpp	2003-11-04 14:00:54 +0300
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <pwd.h>
 
 // detect linux/glibc for the gnu style --args
 #if defined(__linux__) || defined(__linux) || defined(linux)
@@ -248,13 +249,21 @@
    //for creating a raw socket
 
    //now dropping root privileges once and ever
-   setuid(getuid());
+   struct passwd *pwnam = getpwnam("_kdelisa");
+   if (pwnam)
+   {
+	setuid(pwnam->pw_uid);
+   }
+   else
+   {
+	std::cerr << "User _kdelisa not found." << std::endl;
+	exit(1);
+   }
    
    //according to R. Stevens the following three lines 
    //make daemons feel good :)
    setsid();
    chdir("/");
-   umask(0);
    
    getDebug()<<"main starting, dropped root privileges"<<std::endl;
    getDebug()<<"main(): port: "<<portToUse<<" file: "<<configFile<<std::endl;
diff -uNr kdenetwork-3.1.4~/lanbrowsing/lisa/strictmain.cpp kdenetwork-3.1.4/lanbrowsing/lisa/strictmain.cpp
--- kdenetwork-3.1.4~/lanbrowsing/lisa/strictmain.cpp	2003-05-21 16:27:37 +0400
+++ kdenetwork-3.1.4/lanbrowsing/lisa/strictmain.cpp	2003-11-04 14:01:54 +0300
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <pwd.h>
 
 // detect linux/glibc for the gnu style --args
 #if defined(__linux__) || defined(__linux) || defined(linux)
@@ -228,13 +229,21 @@
    //for creating a raw socket
 
    //now dropping root privileges once and ever
-   setuid(getuid());
+   struct passwd *pwnam = getpwnam("_kdelisa");
+   if (pwnam)
+   {
+	setuid(pwnam->pw_uid);
+   }
+   else
+   {
+	std::cerr << "User _kdelisa not found." << std::endl;
+	exit(1);
+   }
    
    //according to R. Stevens the following three lines 
    //make daemons feel good :)
    setsid();
    chdir("/");
-   umask(0);
    
    getDebug()<<"main starting, dropped root privileges"<<std::endl;
    getDebug()<<"main(): port: "<<portToUse<<" file: "<<configFile<<std::endl;
 
design & coding: Vladimir Lettiev aka crux © 2004-2005