pkgng/pkgng — Issue #120: Global and User package database
Author: sanliturk
Created: 2011-12-16 03:09:22+00:00
State: open

In the new PkgNG :

https://github.com/pkgng/pkgng/blob/master/pkg/add.c

the following statement is written :

if (geteuid() != 0) {
warnx("adding packages can only be done as root");
return (EX_NOPERM);
}

Instead of the above statement , is it possible to use a statement
as follows ( which it may be defined as a function to be called from all the related
functions / programs ) :

if (geteuid() == 0) {

package_db_path = ... global path name ... , etc. ;

PKGDB_PLACE = PKGDB_DEFAULT ... etc.

Prefix_for_the_File_Names = "" ;

} else
{

package_db_path = ... local path name , ie.
in $HOME about user path name ... , etc. ;

PKGDB_PLACE = PKGDB_USER ... etc.

Prefix_for_the_File_Names = $HOME ;

}

if (pkgdb_open(&db, PKGDB_PLACE) != EPKG_OK) {
return (EX_IOERR);
}

( Replace PKGDB_PLACE by a suitable name ... )

( Prefix_for_the_File_Names will be appended in front of the all the file names of
installed package to enable them to store into user related directories .
If they do not exist , they will be created , such as

$HOME/lib
$HOME/usr
$HOME/var ... etc.
)

The user may define a suitable $PATH for herself/himself .
I

In that way , it will be possible to install packages into user home directory ,
instead of global package directory .

For security concerns , user-installed packages will not be usable globally , or
convenient only for the user .