25 $IDEnvVar =
'HTTP_SMUNIVERSALID';
26 if (isset($_SERVER[$IDEnvVar])) {
27 return $_SERVER[$IDEnvVar];
40 $EXT_AUTH_ENABLE =
false;
41 if (array_key_exists(
'EXT_AUTH', $GLOBALS[
'SysConf'])) {
42 if (array_key_exists(
'CONF_EXT_AUTH_ENABLE', $GLOBALS[
'SysConf'][
'EXT_AUTH'])) {
43 $EXT_AUTH_ENABLE = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENABLE'];
46 if ($EXT_AUTH_ENABLE) {
47 $EXT_AUTH_USER_KW = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENV_USER'];
48 $EXT_AUTH_USER = $GLOBALS[
'_SERVER'][
"{$EXT_AUTH_USER_KW}"];
49 if (isset($EXT_AUTH_USER) && !empty($EXT_AUTH_USER)) {
50 if ($GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_LOWERCASE_USER']) {
51 $EXT_AUTH_USER = strtolower($EXT_AUTH_USER);
53 $out[
'useAuthExternal'] =
true;
54 $out[
'loginAuthExternal'] = $EXT_AUTH_USER;
55 $out[
'passwordAuthExternal'] = sha1($EXT_AUTH_USER);
56 $EXT_AUTH_MAIL_KW = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENV_MAIL'];
57 $out[
'emailAuthExternal'] = $GLOBALS[
'_SERVER'][
"{$EXT_AUTH_MAIL_KW}"];
58 $EXT_AUTH_DESC_KW = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENV_DESC'];
59 $out[
'descriptionAuthExternal'] = $GLOBALS[
'_SERVER'][
"{$EXT_AUTH_DESC_KW}"];
63 return $out[
'useAuthExternal'] =
false;
78 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
80 $user_passwd_file = getenv(
"HOME") .
"/.fossology.rc";
81 if (empty($user) && empty($passwd) && file_exists($user_passwd_file)) {
82 $user_passwd_array = parse_ini_file($user_passwd_file,
true, INI_SCANNER_RAW);
85 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'user'])) {
86 $user = $user_passwd_array[
'user'];
88 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'username'])) {
89 $user = $user_passwd_array[
'username'];
91 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'groupname'])) {
92 $group = $user_passwd_array[
'groupname'];
94 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'password'])) {
95 $passwd = $user_passwd_array[
'password'];
104 echo
"FATAL: You should add '--username USERNAME' when running OR add " .
105 "'username=USERNAME' in ~/.fossology.rc before running.\n";
108 if (empty($passwd)) {
109 echo
"The user is: $user, please enter the password:\n";
110 system(
'stty -echo');
111 $passwd =
trim(fgets(STDIN));
113 if (empty($passwd)) {
114 echo
"You entered an empty password.\n";
118 if (! empty($user)) {
119 $userDao = $GLOBALS[
'container']->get(
'dao.user');
121 $row = $userDao->getUserAndDefaultGroupByUserName($user);
122 }
catch (Exception $e) {
123 echo $e->getMessage(),
"\n";
126 $userId = $row[
'user_pk'];
127 $SysConf[
'auth'][
'UserId'] = $userId;
130 $group = $row[
'group_name'];
131 $groupId = $row[
'group_fk'];
133 $rowGroup = $dbManager->getSingleRow(
135 FROM group_user_member INNER JOIN groups ON groups.group_pk = group_user_member.group_fk
136 WHERE user_fk = $1 AND group_name = $2", array($userId, $group),
137 __METHOD__ .
".lookUpGroup");
138 if (
false === $rowGroup) {
139 echo
"User is not in group.\n";
142 $groupId = $rowGroup[
'group_pk'];
144 $SysConf[
'auth'][
'GroupId'] = $groupId;
145 if (empty($groupId)) {
146 echo
"Group '$group' not found.\n";
150 if (! empty($row[
'user_pass'])) {
151 $options = array(
'cost' => 10);
152 if (password_verify($passwd, $row[
'user_pass'])) {
153 if (password_needs_rehash($row[
'user_pass'], PASSWORD_DEFAULT, $options)) {
154 $newHash = password_hash($passwd, PASSWORD_DEFAULT, $options);
159 }
else if (! empty($row[
'user_seed'])) {
160 $passwd_hash = sha1($row[
'user_seed'] . $passwd);
162 if (strcmp($passwd_hash, $row[
'user_pass']) == 0) {
163 $newHash = password_hash($passwd, PASSWORD_DEFAULT, $options);
168 echo
"User name or password is invalid.\n";
188 $ADMIN_PERMISSION = 10;
189 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
192 $row = $dbManager->getSingleRow(
194 FROM upload INNER JOIN users ON users.user_pk = upload.user_fk
195 WHERE users.user_name = $1 AND upload.upload_pk = $2",
196 array($user, $upload),
197 __METHOD__.
".checkUpload"
206 $row = $dbManager->getSingleRow(
209 WHERE user_name = $1 AND user_perm = $2",
210 array($user, $ADMIN_PERMISSION),
211 __METHOD__.
".checkPerm"
229 $sysconfig = $GLOBALS[
'SysConf'][
'SYSCONFIG'];
230 if (! array_key_exists(
'PasswdPolicy', $sysconfig) ||
231 $sysconfig[
'PasswdPolicy'] ==
'false') {
243 $sysconfig = $GLOBALS[
'SysConf'][
'SYSCONFIG'];
248 $min =
trim($sysconfig[
'PasswdPolicyMinChar']);
249 $max =
trim($sysconfig[
'PasswdPolicyMaxChar']);
250 if (!empty($min) || !empty($max)) {
254 $min = intval($min) < 0 ? 0 : $min;
255 $max = intval($max) < 0 ? 0 : $max;
256 $limit =
'{' . $min .
",$max}";
259 $charset =
"a-zA-Z\\d";
260 if ($sysconfig[
'PasswdPolicyLower'] ==
'true') {
261 $lookAhead .=
'(?=.*[a-z])';
263 if ($sysconfig[
'PasswdPolicyUpper'] ==
'true') {
264 $lookAhead .=
'(?=.*[A-Z])';
266 if ($sysconfig[
'PasswdPolicyDigit'] ==
'true') {
267 $lookAhead .=
'(?=.*\\d)';
269 $special =
trim($sysconfig[
'PasswdPolicySpecial']);
270 if (!empty($special)) {
271 $lookAhead .=
"(?=.*[$special])";
272 $charset .= $special;
273 $charset =
'[' . $charset .
']';
277 return $lookAhead . $charset . $limit;
286 $sysconfig = $GLOBALS[
'SysConf'][
'SYSCONFIG'];
288 return "No policy defined.";
290 $limit =
"Any length.";
291 $min =
trim($sysconfig[
'PasswdPolicyMinChar']);
292 $max =
trim($sysconfig[
'PasswdPolicyMaxChar']);
293 if (!empty($min) || !empty($max)) {
297 $limit =
"Minimum $min";
299 $limit .=
", maximum $max";
301 $limit .=
" characters.";
304 if ($sysconfig[
'PasswdPolicyLower'] ==
'true') {
305 $others[] =
"lower case";
307 if ($sysconfig[
'PasswdPolicyUpper'] ==
'true') {
308 $others[] =
"upper case";
310 if ($sysconfig[
'PasswdPolicyDigit'] ==
'true') {
313 if (!empty($others)) {
314 $others =
"At least one " . join(
", ", $others);
318 $special =
trim($sysconfig[
'PasswdPolicySpecial']);
319 if (!empty($special)) {
320 if (!empty($others)) {
323 $others .=
" one of <em>$special</em>";
325 return "$limit $others.";
generate_password_policy_string()
read_permission($upload, $user)
Check if the user has the permission to read the copyright/license/etc information of this upload.
siteminder_check()
Check if SiteMinder is enabled.
generate_password_policy()
account_check(&$user, &$passwd, &$group="")
check if this account is correct
auth_external_check()
Check if the external HTTP authentication is enabled. The mapping variables should be configured in f...
update_password_hash($User, $Hash)
Update user password hash.
char * trim(char *ptext)
Trimming whitespace.