36 $IDEnvVar =
'HTTP_SMUNIVERSALID';
37 if (isset($_SERVER[$IDEnvVar])) {
38 $SEA = $_SERVER[$IDEnvVar];
52 $EXT_AUTH_ENABLE =
false;
53 if (array_key_exists(
'EXT_AUTH', $GLOBALS[
'SysConf'])) {
54 if (array_key_exists(
'CONF_EXT_AUTH_ENABLE', $GLOBALS[
'SysConf'][
'EXT_AUTH'])) {
55 $EXT_AUTH_ENABLE = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENABLE'];
58 if ($EXT_AUTH_ENABLE) {
59 $EXT_AUTH_USER_KW = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENV_USER'];
60 $EXT_AUTH_USER = $GLOBALS[
'_SERVER'][
"{$EXT_AUTH_USER_KW}"];
61 if (isset($EXT_AUTH_USER) && !empty($EXT_AUTH_USER)) {
62 if ($GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_LOWERCASE_USER']) {
63 $EXT_AUTH_USER = strtolower($EXT_AUTH_USER);
65 $out[
'useAuthExternal'] =
true;
66 $out[
'loginAuthExternal'] = $EXT_AUTH_USER;
67 $out[
'passwordAuthExternal'] = sha1($EXT_AUTH_USER);
68 $EXT_AUTH_MAIL_KW = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENV_MAIL'];
69 $out[
'emailAuthExternal'] = $GLOBALS[
'_SERVER'][
"{$EXT_AUTH_MAIL_KW}"];
70 $EXT_AUTH_DESC_KW = $GLOBALS[
'SysConf'][
'EXT_AUTH'][
'CONF_EXT_AUTH_ENV_DESC'];
71 $out[
'descriptionAuthExternal'] = $GLOBALS[
'_SERVER'][
"{$EXT_AUTH_DESC_KW}"];
75 return $out[
'useAuthExternal'] =
false;
90 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
92 $user_passwd_file = getenv(
"HOME") .
"/.fossology.rc";
93 if (empty($user) && empty($passwd) && file_exists($user_passwd_file)) {
94 $user_passwd_array = parse_ini_file($user_passwd_file,
true, INI_SCANNER_RAW);
97 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'user'])) {
98 $user = $user_passwd_array[
'user'];
100 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'username'])) {
101 $user = $user_passwd_array[
'username'];
103 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'groupname'])) {
104 $group = $user_passwd_array[
'groupname'];
106 if (! empty($user_passwd_array) && ! empty($user_passwd_array[
'password'])) {
107 $passwd = $user_passwd_array[
'password'];
116 echo
"FATAL: You should add '--username USERNAME' when running OR add " .
117 "'username=USERNAME' in ~/.fossology.rc before running.\n";
120 if (empty($passwd)) {
121 echo
"The user is: $user, please enter the password:\n";
122 system(
'stty -echo');
123 $passwd =
trim(fgets(STDIN));
125 if (empty($passwd)) {
126 echo
"You entered an empty password.\n";
130 if (! empty($user)) {
131 $userDao = $GLOBALS[
'container']->get(
'dao.user');
133 $row = $userDao->getUserAndDefaultGroupByUserName($user);
134 }
catch (Exception $e) {
135 echo $e->getMessage(),
"\n";
138 $userId = $row[
'user_pk'];
139 $SysConf[
'auth'][
'UserId'] = $userId;
142 $group = $row[
'group_name'];
143 $groupId = $row[
'group_fk'];
145 $rowGroup = $dbManager->getSingleRow(
147 FROM group_user_member INNER JOIN groups ON groups.group_pk = group_user_member.group_fk 148 WHERE user_fk = $1 AND group_name = $2", array($userId, $group),
149 __METHOD__ .
".lookUpGroup");
150 if (
false === $rowGroup) {
151 echo
"User is not in group.\n";
154 $groupId = $rowGroup[
'group_pk'];
156 $SysConf[
'auth'][
'GroupId'] = $groupId;
157 if (empty($groupId)) {
158 echo
"Group '$group' not found.\n";
162 if (! empty($row[
'user_seed']) && ! empty($row[
'user_pass'])) {
163 $passwd_hash = sha1($row[
'user_seed'] . $passwd);
164 if (strcmp($passwd_hash, $row[
'user_pass']) != 0) {
165 echo
"User name or password is invalid.\n";
184 $ADMIN_PERMISSION = 10;
185 $dbManager = $GLOBALS[
'container']->get(
'db.manager');
188 $row = $dbManager->getSingleRow(
190 FROM upload INNER JOIN users ON users.user_pk = upload.user_fk 191 WHERE users.user_name = $1 AND upload.upload_pk = $2",
192 array($user, $upload),
193 __METHOD__.
".checkUpload" 202 $row = $dbManager->getSingleRow(
205 WHERE user_name = $1 AND user_perm = $2",
206 array($user, $ADMIN_PERMISSION),
207 __METHOD__.
".checkPerm" account_check(&$user, &$passwd, &$group="")
check if this account is correct
siteminder_check()
Check if SiteMinder is enabled.
read_permission($upload, $user)
Check if the user has the permission to read the copyright/license/etc information of this upload...
auth_external_check()
Check if the external HTTP authentication is enabled. The mapping variables should be configured in f...
char * trim(char *ptext)
Trimming whitespace.