Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
zmarano committed Jan 29, 2018
2 parents 3cef8c3 + adf7bf7 commit a183285
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
19 changes: 16 additions & 3 deletions google_compute_engine_oslogin/bin/google_oslogin_control
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,22 @@ add_to_nss_config() {

add_to_pam_config() {
remove_from_config ${pam_config}
sed -i "/account.*pam_nologin.so/ a${added_comment}\n${pam_admin}" ${pam_config}.new
sed -i "/account.*pam_nologin.so/ a${added_comment}\n${pam_login}" ${pam_config}.new
sed -i "/pam_loginuid.so/ a${added_comment}\n${pam_homedir}" ${pam_config}.new
if grep -q -s "ID=cos" /etc/os-release; then
# For COS simply prepend the new config.
added_config="\
${added_comment}
${pam_admin}
${added_comment}
${pam_login}
${added_comment}
${pam_homedir}
"
echo "${added_config}$(cat ${pam_config}.new)" > ${pam_config}.new
else
sed -i "/account.*pam_nologin.so/ a${added_comment}\n${pam_admin}" ${pam_config}.new
sed -i "/account.*pam_nologin.so/ a${added_comment}\n${pam_login}" ${pam_config}.new
sed -i "/pam_loginuid.so/ a${added_comment}\n${pam_homedir}" ${pam_config}.new
fi
}

restart_service() {
Expand Down
6 changes: 5 additions & 1 deletion google_compute_engine_oslogin/utils/oslogin_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ bool HttpGet(const string& url, string* response, long* http_code) {
struct curl_slist* header_list = NULL;
header_list = curl_slist_append(header_list, "Metadata-Flavor: Google");
if (header_list == NULL) {
curl_easy_cleanup(curl);
curl_global_cleanup();
return false;
}
Expand All @@ -171,14 +172,17 @@ bool HttpGet(const string& url, string* response, long* http_code) {

code = curl_easy_perform(curl);
if (code != CURLE_OK) {
curl_easy_cleanup(curl);
curl_global_cleanup();
return false;
}
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, http_code);
} while (retry_count++ < kMaxRetries && *http_code == 500);
curl_slist_free_all(header_list);
curl_global_cleanup();
}
*response = response_stream.str();
curl_easy_cleanup(curl);
curl_global_cleanup();
return true;
}

Expand Down
5 changes: 2 additions & 3 deletions google_config/bin/google_set_hostname
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ if [ -n "$new_host_name" ]; then
hostnamectl=$( which hostnamectl 2> /dev/null )
if [ -x "$hostnamectl" ]; then
$hostnamectl set-hostname "$new_host_name"
else
# Assume hostname command exists.
hostname "${new_host_name%%.*}"
fi
# Also set the transient hostname.
hostname "${new_host_name%%.*}"

# If NetworkManager is installed set the hostname with nmcli.
# to resolve issues with NetworkManager resetting the hostname
Expand Down

0 comments on commit a183285

Please sign in to comment.