Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Set up fink-bld parameters via "fink configure"

  • Loading branch information...
commit 5236c4054400da1098f307e4ef08892f75ced1ce 1 parent ddce407
Alexander Hansen akhansen authored
Showing with 117 additions and 3 deletions.
  1. +117 −3 perlmod/Fink/Configure.pm
120 perlmod/Fink/Configure.pm
View
@@ -71,8 +71,9 @@ These functions handle managing changes in the fink.conf file.
# 0: Default value, fink < 0.24.0
# 1: Added ConfFileCompatVersion, UseBinaryDist, fink 0.24.0
# 2: Added MaxBuildJobs, fink 0.30.1 (belated bump)
+# 3: Added AutoUid, AutoUidMin, AutoUidMax, FinkBldUid, fink 0.33.0
#
-our $conf_file_compat_version = 2;
+our $conf_file_compat_version = 3;
=head2 Exported Variables
@@ -136,6 +137,8 @@ Configure everything but the mirrors
sub choose_misc {
my ($otherdir, $verbose);
my ($proxy_prompt, $proxy, $passive_ftp, $same_for_ftp, $binary_dist);
+ my ($auto_uid, $uid_min, $uid_max, $fink_conf_uid, $real_uid, $real_gid,
+ $do_uid);
# normal configuration
$otherdir =
@@ -192,7 +195,6 @@ sub choose_misc {
}
$config->set_param("UseBinaryDist", $binary_dist ? "true" : "false");
-
print "\n";
if ($config->param("Distribution") ge "10.7") {
@@ -256,7 +258,119 @@ print_breaking("The selfupdate method has not been set yet, so you ".
"If you are interested in the \"unstable\" tree, first run \"fink ".
"selfupdate\" and then run \"fink configure\" again.");
}
-
+
+ # build user settings
+ print "\n";
+ &print_breaking("Fink build user settings");
+ $_ = `id -P fink-bld 2>&1`;
+ ($real_uid,$real_gid) = /.*:.*:(\d+):(\d+):.*:.*:.*:.*:.*/ ;
+ $auto_uid = $config->param_boolean("AutoUid","True");
+ $uid_min = $config->param("AutoUidMin",600);
+ $uid_max = $config->param("AutoUidMax",699);
+ if ($real_uid) {
+ $fink_conf_uid = $config->param("FinkBldUid",$real_uid);
+ } else {
+ $fink_conf_uid = $config->param("FinkBldUid");
+ }
+ $do_uid=1; #default
+ if ($real_uid && $real_gid) {
+ $do_uid = &prompt_boolean( "Fink's build user is currently set up. ".
+ "Do you want to reconfigure it?", default => 0);
+ unless ($do_uid) {
+ &print_breaking("Using UID:$real_uid") unless $fink_conf_uid;
+ }
+ }
+ if ($do_uid) {
+ my $id;
+ my $fail_msg = "WARNING: No UID/GID set for Fink's build user. ".
+ "fink can still build as the 'nobody' user, but ".
+ "we recommend running 'fink configure' again or ".
+ "otherwise installing the build user.";
+ $auto_uid = &prompt_boolean("Fink can set the UID and GID of its build user ".
+ "dynamically to find unused values in a safe ".
+ "range. This is recommended unless you need ".
+ "to have a specific UID/GID e.g. due to a ".
+ "policy on your network. Allow Fink to set ".
+ "the UID GID dynamically?", default => $auto_uid);
+ if ($auto_uid) {
+ IDRANGE: while (1) {
+ &print_breaking("The current ID search range is $uid_min-$uid_max.");
+ IDSCAN: for ($id = $uid_min; $id <= $uid_max; $id++) {
+ last IDSCAN unless (getpwuid $id or getgrgid $id);
+ print "$id failed\n";
+ print "UID:", (getpwuid $id), "\n";
+ print "GID:", (getgrgid $id), "\n";
+ if ($id == $uid_max) {
+ $id = -1;
+ last IDSCAN;
+ }
+ }
+ if ( $id > 0 ) {
+ $fink_conf_uid=$id;
+ &print_breaking ("Using $id");
+ last IDRANGE;
+ } else {
+ my $retry = &prompt_boolean("WARNING: Couldn't find an unused ".
+ "group/user id between $uid_min and ".
+ "$uid_max. Try another range?"
+ , default => 1);
+ if ($retry) {
+ my $defmax;
+ my @uid_list;
+ $uid_min = &prompt("Enter minimum ID value:", default => $uid_min);
+ if ($uid_max >= $uid_min) {
+ $defmax = $uid_max;
+ } else {
+ $defmax = $uid_min+1;
+ }
+ $uid_max = &prompt("Enter maximum ID value:", default => $defmax);
+ @uid_list = sort ($uid_min,$uid_max); #ensure max >= min;
+ $uid_min = shift @uid_list;
+ $uid_max = shift @uid_list;
+ redo IDRANGE;
+ } else {
+ &print_breaking($fail_msg);
+ # unset values to keep them from getting entered in fink.conf
+ undef $uid_min;
+ undef $uid_max;
+ undef $auto_uid;
+ undef $fink_conf_uid;
+ last IDRANGE;
+ }
+ }
+ }
+ } else {
+ $auto_uid="false";
+ undef $uid_min;
+ undef $uid_max;
+ MANUAL_UID: while (1) {
+ $id = &prompt("Enter UID/GID value: ");
+ last MANUAL_UID unless (getpwuid $id or getgrgid $id);
+ my $retry = prompt_boolean("$id in use. Try another?");
+ if ($retry) {
+ next MANUAL_UID;
+ } else {
+ $id = -1;
+ last MANUAL_UID;
+ }
+ }
+ if ( $id > 0 ) {
+ $fink_conf_uid=$id;
+ &print_breaking ("Using $id");
+ } else {
+ &print_breaking($fail_msg);
+ # unset values to keep them from getting entered in fink.conf
+ undef $auto_uid;
+ undef $fink_conf_uid;
+ }
+ }
+ }
+ #write values
+ $config->set_param("AutoUid", $auto_uid);
+ $config->set_param("AutoUidMin",$uid_min);
+ $config->set_param("AutoUidMax",$uid_max);
+ $config->set_param("FinkBldUid",$fink_conf_uid);
+
$verbose = $config->param_default("Verbose", 1);
$verbose =
&prompt_selection("How verbose should Fink be?",
Please sign in to comment.
Something went wrong with that request. Please try again.