Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package google-guest-oslogin for 
openSUSE:Factory checked in at 2021-02-23 20:20:26
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/google-guest-oslogin (Old)
 and      /work/SRC/openSUSE:Factory/.google-guest-oslogin.new.2378 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "google-guest-oslogin"

Tue Feb 23 20:20:26 2021 rev:5 rq:862627 version:20210108.00

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/google-guest-oslogin/google-guest-oslogin.changes    
    2020-11-26 23:13:00.692959248 +0100
+++ 
/work/SRC/openSUSE:Factory/.google-guest-oslogin.new.2378/google-guest-oslogin.changes
      2021-02-23 20:22:11.443750435 +0100
@@ -1,0 +2,7 @@
+Tue Jan 12 10:43:53 UTC 2021 - John Paul Adrian Glaubitz 
<[email protected]>
+
+- Update to version 20210108.00
+  * Update logic in the cache_refresh binary (#52)
+  * remove old unused workflow files (#49)
+
+-------------------------------------------------------------------

Old:
----
  google-guest-oslogin-20200925.00.tar.gz

New:
----
  google-guest-oslogin-20210108.00.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ google-guest-oslogin.spec ++++++
--- /var/tmp/diff_new_pack.iagY0O/_old  2021-02-23 20:22:11.971750902 +0100
+++ /var/tmp/diff_new_pack.iagY0O/_new  2021-02-23 20:22:11.971750902 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package google-guest-oslogin
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           google-guest-oslogin
-Version:        20200925.00
+Version:        20210108.00
 Release:        0
 Summary:        Google Cloud Guest OS Login
 License:        Apache-2.0

++++++ google-guest-oslogin-20200925.00.tar.gz -> 
google-guest-oslogin-20210108.00.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/guest-oslogin-20200925.00/packaging/build_deb.sh 
new/guest-oslogin-20210108.00/packaging/build_deb.sh
--- old/guest-oslogin-20200925.00/packaging/build_deb.sh        2020-09-25 
20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/packaging/build_deb.sh        1970-01-01 
01:00:00.000000000 +0100
@@ -1,53 +0,0 @@
-#!/bin/bash
-# Copyright 2018 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e
-
-DEBIAN_FRONTEND=noninteractive
-dpkg_working_dir="/tmp/debpackage"
-
-. packaging/common.sh
-
-DEB=$(cut -d. -f1 </etc/debian_version)
-if [[ -z $DEB ]]; then
-  echo "Can't determine debian version of build host"
-  exit 1
-fi
-
-# Build dependencies.
-echo "Installing dependencies."
-try_command apt-get -y install make g++ libcurl4-openssl-dev libjson-c-dev \
-  libpam-dev debhelper devscripts build-essential >/dev/null
-
-dpkg-checkbuilddeps packaging/debian/control
-
-echo "Building package"
-[[ -d $dpkg_working_dir ]] && rm -rf $dpkg_working_dir
-mkdir $dpkg_working_dir
-tar czvf /tmp/debpackage/${PKGNAME}_${VERSION}.orig.tar.gz  --exclude .git \
-  --exclude packaging --transform "s/^\./${PKGNAME}-${VERSION}/" .
-
-working_dir=${PWD}
-cd $dpkg_working_dir
-tar xzvf ${PKGNAME}_${VERSION}.orig.tar.gz
-
-cd ${PKGNAME}-${VERSION}
-
-cp -r ${working_dir}/packaging/debian ./
-echo "Building on Debian ${DEB}, modifying latest changelog entry."
-sed -r -i"" "1s/^${PKGNAME} \((.*)\) (.+;.*)/${PKGNAME} (\1+deb${DEB}) \2/" \
-  debian/changelog
-
-DEB_BUILD_OPTIONS=noddebs debuild -us -uc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/guest-oslogin-20200925.00/packaging/build_packages_wf.json 
new/guest-oslogin-20210108.00/packaging/build_packages_wf.json
--- old/guest-oslogin-20200925.00/packaging/build_packages_wf.json      
2020-09-25 20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/packaging/build_packages_wf.json      
1970-01-01 01:00:00.000000000 +0100
@@ -1,193 +0,0 @@
-{
-  "Name": "build-packages",
-  "Sources": {
-    "startup_deb.sh": "./daisy_startupscript_deb.sh",
-    "startup_rpm.sh": "./daisy_startupscript_rpm.sh",
-    "common.sh": "./common.sh"
-  },
-  "Vars": {
-    "gcs_path": {
-      "Value": "${SCRATCHPATH}/packages",
-      "Description": "GCS path to dump the built packages in: 
gs://my-bucket/packages"
-    },
-    "base_repo": {
-      "Value": "GoogleCloudPlatform",
-      "Description": "Base GitHub repo"
-    },
-    "repo": {
-      "Value": "guest-oslogin",
-      "Description": "Github Repository"
-    },
-    "pull_ref": {
-      "Value": "master",
-      "Description": "Branch to build from"
-    }
-  },
-  "Steps": {
-    "build-packages": {
-      "CreateInstances": [
-        {
-          "disks": [
-            {
-              "initializeParams": {
-                "diskType": "pd-ssd",
-                "sourceImage": 
"projects/debian-cloud/global/images/family/debian-9"
-              }
-            }
-          ],
-          "Metadata": {
-            "base-repo": "${base_repo}",
-            "repo": "${repo}",
-            "pull-ref": "${pull_ref}"
-          },
-          "machineType": "n1-standard-2",
-          "name": "inst-build-deb9",
-          "StartupScript": "startup_deb.sh",
-             "Scopes": 
["https://www.googleapis.com/auth/devstorage.read_write";]
-        },
-        {
-          "disks": [
-            {
-              "initializeParams": {
-                "diskType": "pd-ssd",
-                "sourceImage": 
"projects/debian-cloud/global/images/family/debian-10"
-              }
-            }
-          ],
-          "Metadata": {
-            "base-repo": "${base_repo}",
-            "repo": "${repo}",
-            "pull-ref": "${pull_ref}"
-          },
-          "machineType": "n1-standard-2",
-          "name": "inst-build-deb10",
-          "StartupScript": "startup_deb.sh",
-             "Scopes": 
["https://www.googleapis.com/auth/devstorage.read_write";]
-        },
-        {
-          "disks": [
-            {
-              "initializeParams": {
-                "diskType": "pd-ssd",
-                "sourceImage": 
"projects/centos-cloud/global/images/family/centos-6"
-              }
-            }
-          ],
-          "Metadata": {
-            "base-repo": "${base_repo}",
-            "repo": "${repo}",
-            "pull-ref": "${pull_ref}"
-          },
-          "machineType": "n1-standard-2",
-          "name": "inst-build-el6",
-          "StartupScript": "startup_rpm.sh",
-             "Scopes": 
["https://www.googleapis.com/auth/devstorage.read_write";]
-        },
-        {
-          "disks": [
-            {
-              "initializeParams": {
-                "diskType": "pd-ssd",
-                "sourceImage": 
"projects/centos-cloud/global/images/family/centos-7"
-              }
-            }
-          ],
-          "Metadata": {
-            "base-repo": "${base_repo}",
-            "repo": "${repo}",
-            "pull-ref": "${pull_ref}"
-          },
-          "machineType": "n1-standard-2",
-          "name": "inst-build-el7",
-          "StartupScript": "startup_rpm.sh",
-             "Scopes": 
["https://www.googleapis.com/auth/devstorage.read_write";]
-        },
-        {
-          "disks": [
-            {
-              "initializeParams": {
-                "diskType": "pd-ssd",
-                "sourceImage": 
"projects/rhel-cloud/global/images/family/rhel-8"
-              }
-            }
-          ],
-          "Metadata": {
-            "base-repo": "${base_repo}",
-            "repo": "${repo}",
-            "pull-ref": "${pull_ref}"
-          },
-          "machineType": "n1-standard-2",
-          "name": "inst-build-el8",
-          "StartupScript": "startup_rpm.sh",
-             "Scopes": 
["https://www.googleapis.com/auth/devstorage.read_write";]
-        }
-      ]
-    },
-    "wait-for-build": {
-      "Timeout": "10m",
-      "WaitForInstancesSignal": [
-        {
-          "Name": "inst-build-deb9",
-          "SerialOutput": {
-            "Port": 1,
-            "SuccessMatch": "Package build success",
-            "FailureMatch": "build failed",
-            "StatusMatch": "build status"
-          }
-        },
-        {
-          "Name": "inst-build-deb10",
-          "SerialOutput": {
-            "Port": 1,
-            "SuccessMatch": "Package build success",
-            "FailureMatch": "build failed",
-            "StatusMatch": "build status"
-          }
-        },
-        {
-          "Name": "inst-build-el6",
-          "SerialOutput": {
-            "Port": 1,
-            "SuccessMatch": "Package build success",
-            "FailureMatch": "build failed",
-            "StatusMatch": "build status"
-          }
-        },
-        {
-          "Name": "inst-build-el7",
-          "SerialOutput": {
-            "Port": 1,
-            "SuccessMatch": "Package build success",
-            "FailureMatch": "build failed",
-            "StatusMatch": "build status"
-          }
-        },
-        {
-          "Name": "inst-build-el8",
-          "SerialOutput": {
-            "Port": 1,
-            "SuccessMatch": "Package build success",
-            "FailureMatch": "build failed",
-            "StatusMatch": "build status"
-          }
-        }
-      ]
-    },
-    "copy-packages": {
-      "CopyGCSObjects": [
-        {
-          "Source": "${OUTSPATH}/",
-          "Destination": "${gcs_path}/"
-        }
-      ]
-    }
-  },
-  "Dependencies": {
-    "wait-for-build": [
-      "build-packages"
-    ],
-    "copy-packages": [
-      "wait-for-build"
-    ]
-  }
-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/guest-oslogin-20200925.00/packaging/build_rpm.sh 
new/guest-oslogin-20210108.00/packaging/build_rpm.sh
--- old/guest-oslogin-20200925.00/packaging/build_rpm.sh        2020-09-25 
20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/packaging/build_rpm.sh        1970-01-01 
01:00:00.000000000 +0100
@@ -1,40 +0,0 @@
-#!/bin/bash
-# Copyright 2018 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -e
-
-rpm_working_dir=/tmp/rpmpackage/
-
-. packaging/common.sh
-
-yum -y install rpmdevtools make gcc-c++ json-c \
-  libcurl-devel pam-devel boost-devel json-c-devel
-
-if grep -q '^\(CentOS\|Red Hat\)[^0-9]*8\..' /etc/redhat-release; then
-  yum -y install python3-policycoreutils
-else
-  yum -y install policycoreutils-python
-fi
-
-rm -rf /tmp/rpmpackage
-mkdir -p ${rpm_working_dir}/{SOURCES,SPECS}
-
-cp packaging/${PKGNAME}.spec ${rpm_working_dir}/SPECS/
-
-tar czvf ${rpm_working_dir}/SOURCES/${PKGNAME}_${VERSION}.orig.tar.gz \
-  --exclude .git --exclude packaging --transform 
"s/^\./${PKGNAME}-${VERSION}/" .
-
-rpmbuild --define "_topdir ${rpm_working_dir}/" --define "_version ${VERSION}" 
\
-  --define "_arch x86_64" -ba ${rpm_working_dir}/SPECS/${PKGNAME}.spec
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/guest-oslogin-20200925.00/packaging/common.sh 
new/guest-oslogin-20210108.00/packaging/common.sh
--- old/guest-oslogin-20200925.00/packaging/common.sh   2020-09-25 
20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/packaging/common.sh   1970-01-01 
01:00:00.000000000 +0100
@@ -1,56 +0,0 @@
-#!/bin/bash
-# Copyright 2019 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-export PKGNAME="google-compute-engine-oslogin"
-export VERSION="20191018.00"
-
-function exit_error() {
-  echo "build failed: $0:$1 \"$BASH_COMMAND\" returned $?"
-  exit 1
-}
-
-trap 'exit_error $LINENO' ERR
-
-function git_checkout() {
-  # Checks out a repo at a specified commit or ref into a specified directory.
-
-  BASE_REPO="$1"
-  REPO="$2"
-  PULL_REF="$3"
-
-  # pull the repository from github - start
-  mkdir -p $REPO
-  cd $REPO
-  git init
-
-  # fetch only the branch that we want to build
-  git_command="git fetch https://github.com/${BASE_REPO}/${REPO}.git 
${PULL_REF:-"master"}:packaging"
-  echo "Running ${git_command}"
-  $git_command
-
-  git checkout packaging
-}
-
-function try_command() {
-  n=0
-  while ! "$@"; do
-    echo "try $n to run $@"
-    if [[ $n -gt 3 ]]; then
-      return 1
-    fi
-    ((n++))
-    sleep 5
-  done
-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/guest-oslogin-20200925.00/packaging/daisy_startupscript_deb.sh 
new/guest-oslogin-20210108.00/packaging/daisy_startupscript_deb.sh
--- old/guest-oslogin-20200925.00/packaging/daisy_startupscript_deb.sh  
2020-09-25 20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/packaging/daisy_startupscript_deb.sh  
1970-01-01 01:00:00.000000000 +0100
@@ -1,39 +0,0 @@
-#!/bin/bash
-# Copyright 2019 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-URL="http://metadata/computeMetadata/v1/instance/attributes";
-GCS_PATH=$(curl -f -H Metadata-Flavor:Google ${URL}/daisy-outs-path)
-SRC_PATH=$(curl -f -H Metadata-Flavor:Google ${URL}/daisy-sources-path)
-BASE_REPO=$(curl -f -H Metadata-Flavor:Google ${URL}/base-repo)
-REPO=$(curl -f -H Metadata-Flavor:Google ${URL}/repo)
-PULL_REF=$(curl -f -H Metadata-Flavor:Google ${URL}/pull-ref)
-
-DEBIAN_FRONTEND=noninteractive
-
-echo "Started build..."
-
-gsutil cp "${SRC_PATH}/common.sh" ./
-
-. common.sh
-
-try_command apt-get -y update
-try_command apt-get install -y git-core
-
-git_checkout "$BASE_REPO" "$REPO" "$PULL_REF"
-
-./packaging/build_deb.sh
-gsutil cp /tmp/debpackage/*.deb "${GCS_PATH}/"
-
-echo "Package build success: built `echo /tmp/debpackage/*.deb|xargs -n1 
basename`"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/guest-oslogin-20200925.00/packaging/daisy_startupscript_rpm.sh 
new/guest-oslogin-20210108.00/packaging/daisy_startupscript_rpm.sh
--- old/guest-oslogin-20200925.00/packaging/daisy_startupscript_rpm.sh  
2020-09-25 20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/packaging/daisy_startupscript_rpm.sh  
1970-01-01 01:00:00.000000000 +0100
@@ -1,54 +0,0 @@
-#!/bin/bash
-# Copyright 2019 Google Inc. All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-URL="http://metadata/computeMetadata/v1/instance/attributes";
-GCS_PATH=$(curl -f -H Metadata-Flavor:Google ${URL}/daisy-outs-path)
-SRC_PATH=$(curl -f -H Metadata-Flavor:Google ${URL}/daisy-sources-path)
-BASE_REPO=$(curl -f -H Metadata-Flavor:Google ${URL}/base-repo)
-REPO=$(curl -f -H Metadata-Flavor:Google ${URL}/repo)
-PULL_REF=$(curl -f -H Metadata-Flavor:Google ${URL}/pull-ref)
-
-echo "Started build..."
-
-gsutil cp "${SRC_PATH}/common.sh" ./
-
-. common.sh
-
-# Install git2 as this is not available in centos 6/7
-RELEASE_RPM=$(rpm -qf /etc/redhat-release)
-RELEASE=$(rpm -q --qf '%{VERSION}' ${RELEASE_RPM})
-case ${RELEASE} in
-  6*) 
-    try_command yum install -y https://rhel6.iuscommunity.org/ius-release.rpm
-    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-${RELEASE}
-    yum install -y git2u
-    ;;
-  7*) 
-    try_command yum install -y https://rhel7.iuscommunity.org/ius-release.rpm
-    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-${RELEASE}
-    yum install -y git2u
-    ;;
-  *) 
-    yum install -y git
-    ;;
-esac
-
-git_checkout "$BASE_REPO" "$REPO" "$PULL_REF"
-
-packaging/build_rpm.sh
-gsutil cp /tmp/rpmpackage/RPMS/x86_64/*.rpm "${GCS_PATH}/"
-gsutil cp /tmp/rpmpackage/SRPMS/*.rpm "${GCS_PATH}/"
-
-echo "Package build success: built `echo 
/tmp/rpmpackage/RPMS/x86_64/*.rpm|xargs -n1 basename`"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/guest-oslogin-20200925.00/src/cache_refresh/cache_refresh.cc 
new/guest-oslogin-20210108.00/src/cache_refresh/cache_refresh.cc
--- old/guest-oslogin-20200925.00/src/cache_refresh/cache_refresh.cc    
2020-09-25 20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/src/cache_refresh/cache_refresh.cc    
2021-01-08 19:48:30.000000000 +0100
@@ -65,7 +65,6 @@
   chown(kDefaultBackupFilePath, 0, 0);
   chmod(kDefaultBackupFilePath, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
-  int count = 0;
   nss_cache.Reset();
   while (!nss_cache.OnLastPage() || nss_cache.HasNextEntry()) {
     BufferManager buffer_manager(buffer, kPasswdBufferSize);
@@ -76,7 +75,9 @@
         syslog(LOG_ERR, "Malformed passwd entry, skipping");
       } else if (error_code == ENOENT) {
         syslog(LOG_ERR, "Failure getting users, quitting");
-        count = 0;
+        break;
+      } else if (error_code == ENOMSG) {
+        // ENOMSG means OS Login is not enabled.
         break;
       }
       continue;
@@ -87,18 +88,25 @@
     cache_file << pwd.pw_name << ":" << pwd.pw_passwd << ":" << pwd.pw_uid
                << ":" << pwd.pw_gid << ":" << pwd.pw_gecos << ":" << pwd.pw_dir
                << ":" << pwd.pw_shell << "\n";
-    count++;
   }
   cache_file.close();
 
-  if (count > 0) {
-    if (rename(kDefaultBackupFilePath, kDefaultFilePath) != 0) {
-      syslog(LOG_ERR, "Could not move passwd cache file.");
+  if (error_code == ENOMSG) {
+    remove(kDefaultBackupFilePath);
+    return 0;
+  } else if (error_code == ENOENT) {
+    syslog(LOG_ERR, "Failed to get users, not updating passwd cache file, 
removing %s.", kDefaultBackupFilePath);
+    // If the cache file already exists, we don't want to overwrite it on a
+    // server error. So remove the backup file and return here.
+    struct stat buffer;
+    if (stat(kDefaultFilePath, &buffer) == 0) {
       remove(kDefaultBackupFilePath);
+      return 0;
     }
-  } else {
-    // count <= 0
-    syslog(LOG_ERR, "Produced empty passwd cache file, removing %s.", 
kDefaultBackupFilePath);
+  }
+
+  if (rename(kDefaultBackupFilePath, kDefaultFilePath) != 0) {
+    syslog(LOG_ERR, "Error moving %s to %s.", kDefaultBackupFilePath, 
kDefaultFilePath);
     remove(kDefaultBackupFilePath);
   }
 
@@ -121,7 +129,6 @@
   chmod(kDefaultBackupGroupPath, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
 
   struct group grp;
-  int count = 0;
   nss_cache.Reset();
   std::vector<string> users;
   while (!nss_cache.OnLastPage() || nss_cache.HasNextEntry()) {
@@ -133,7 +140,9 @@
         syslog(LOG_ERR, "Malformed group entry, skipping");
       } else if (error_code == ENOENT) {
         syslog(LOG_ERR, "Failure getting groups, quitting");
-        count = 0;
+        break;
+      } else if (error_code == ENOMSG) {
+        // ENOMSG means OS Login is not enabled.
         break;
       }
       continue;
@@ -151,18 +160,25 @@
       cache_file << "," << users[i];
     }
     cache_file << "\n";
-    count++;
   }
   cache_file.close();
 
-  if (count > 0) {
-    if (rename(kDefaultBackupGroupPath, kDefaultGroupPath) != 0) {
-      syslog(LOG_ERR, "Could not move group cache file.");
+  if (error_code == ENOMSG) {
+    remove(kDefaultBackupGroupPath);
+    return 0;
+  } else if (error_code == ENOENT) {
+    syslog(LOG_ERR, "Failed to get groups, not updating passwd cache file, 
removing %s.", kDefaultBackupGroupPath);
+    // If the cache file already exists, we don't want to overwrite it on a
+    // server error. So remove the backup file and return here.
+    struct stat buffer;
+    if (stat(kDefaultGroupPath, &buffer) == 0) {
       remove(kDefaultBackupGroupPath);
+      return 0;
     }
-  } else {
-    // count <= 0
-    syslog(LOG_ERR, "Produced empty group cache file, removing %s.", 
kDefaultBackupGroupPath);
+  }
+
+  if (rename(kDefaultBackupGroupPath, kDefaultGroupPath) != 0) {
+    syslog(LOG_ERR, "Error moving %s to %s.", kDefaultBackupGroupPath, 
kDefaultGroupPath);
     remove(kDefaultBackupGroupPath);
   }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/guest-oslogin-20200925.00/src/oslogin_utils.cc 
new/guest-oslogin-20210108.00/src/oslogin_utils.cc
--- old/guest-oslogin-20200925.00/src/oslogin_utils.cc  2020-09-25 
20:31:10.000000000 +0200
+++ new/guest-oslogin-20210108.00/src/oslogin_utils.cc  2021-01-08 
19:48:30.000000000 +0100
@@ -205,6 +205,8 @@
 //
 // * EINVAL  - current user entry was malformed in some way.
 // * ERANGE  - the page of results did not fit into the provided buffer.
+// * ENOMSG  - a 404 error was received when contacting the metadata server, 
indicating that
+//             OS Login is not enabled in the instance metadata.
 // * ENOENT  - a general failure to load the cache occurred. Behavior of 
retries
 //             following ENOENT is undefined.
 bool NssCache::NssGetpwentHelper(BufferManager* buf, struct passwd* result, 
int* errnop) {
@@ -217,8 +219,14 @@
     }
     string response;
     long http_code = 0;
-    if (!HttpGet(url.str(), &response, &http_code) || http_code != 200 ||
-        response.empty() || !LoadJsonUsersToCache(response)) {
+    bool status = HttpGet(url.str(), &response, &http_code);
+    // 404 means OS Login is not enabled.
+    if (http_code == 404) {
+      *errnop = ENOMSG;
+      return false;
+    }
+    // General failure to load the cache occurred.
+    if (!status || http_code != 200 || response.empty() || 
!LoadJsonGroupsToCache(response)) {
       *errnop = ENOENT;
       return false;
     }
@@ -232,6 +240,8 @@
 //
 // * EINVAL  - current group entry was malformed in some way.
 // * ERANGE  - the page of results did not fit into the provided buffer.
+// * ENOMSG  - a 404 error was received when contacting the metadata server, 
indicating that
+//             OS Login is not enabled in the instance metadata.
 // * ENOENT  - a general failure to load the cache occurred. Behavior of 
retries
 //             following ENOENT is undefined.
 bool NssCache::NssGetgrentHelper(BufferManager* buf, struct group* result, 
int* errnop) {
@@ -244,8 +254,14 @@
     }
     string response;
     long http_code = 0;
-    if (!HttpGet(url.str(), &response, &http_code) || http_code != 200 ||
-        response.empty() || !LoadJsonGroupsToCache(response)) {
+    bool status = HttpGet(url.str(), &response, &http_code);
+    // 404 means OS Login is not enabled.
+    if (http_code == 404) {
+      *errnop = ENOMSG;
+      return false;
+    }
+    // General failure to load the cache occurred.
+    if (!status || http_code != 200 || response.empty() || 
!LoadJsonGroupsToCache(response)) {
       *errnop = ENOENT;
       return false;
     }

Reply via email to