Fautore Install Setting - Id
Parameter: | id |
Type: | string |
default: | root |
Notes: | Not setting this value will have undefined results |
The "id" parameter defines which of two OS commands should be run to obtain the current user id running the script. The two possibilities currently implemented are "id_by_id" and "id_by_whois" which are references respectively to the "id" and "whois" commands. This is one case where adding possible values for a parameter will require coding. Each of the possible values for the "id" parameter are actually function names. Any future parameters added should be exactly the same as the associated function name for clarity.
Adding Possible "id" Parameter Values
Adding a new "id" parameter is a two-step process. The first step is to add the new function for obtaining the current user running the installation to the "Install.pm" PERL module. The second step is to register the new function with the module as being available for use through the configuration file.
Registering the function
Function registration occurs in the "new" function of the Install.pm module by storing a reference to the new function in the "funcs" element of the object class hash. Given the hash is referenced via a variable called "$self," the following template applies:
$self->{'funcs'}{'<function name>'} = \&<function name>;
So, for a new function "id_by_uservar" the registration entry to the "new" function of "Install.pm" would look like:
$self->{'funcs'}{'id_by_uservar'} = \&id_by_uservar;
Additional Considerations
This is kind of a tricky topic that warrants more research (and documentation). There are two problems being solved by this parameter. The first is obviously providing a method to confirm if the account that is supposed to be running the installation is indeed running the installation. The second is to provide a means of doing this by differing means that could be operating system specific so that the correct method is implemented for its corresponding operating system.
One might say "just use PERLs 'getlogin' or 'getpwuid' functions," which is a darn fine suggestion. The problem is that there is also an underlying consideration of "real" and "effective" user ids. When I log in as "steve" and run the "install.pl" script using "sudo" on a Linux system, my real id is "steve" and my effective id is "root." This is also true of using "su" to switch users. It is possible that a site may want only those who know the root password to do the install, or conversely, may want to ensure those doing the install are using sudo and not logged directly into root.
There are further reaching possibilities with including an "and" function to check both levels of login to verify, for example the "real" login "is not root" and the "effective login is root," but that degree of verification is not yet implemented.
At the very least a third parameter, usful enough even to be the default, using "getlogin" or "getpwuid" or "$<", or some combination of the three, is likely a good step to take. This PERL native approach, possible named id_by_perl would work across most platforms (any I can think of) and leaving the other possibilities (id_by_id and id_by_whois) would allow for special circumstances.