diff --git a/internal/pkg/util/copyfile.go b/internal/pkg/util/copyfile.go index 5c858e48..ef47b890 100644 --- a/internal/pkg/util/copyfile.go +++ b/internal/pkg/util/copyfile.go @@ -27,7 +27,7 @@ func CopyFile(src string, dst string) error { return err } - dstFD, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE, srcInfo.Mode()) + dstFD, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, srcInfo.Mode()) if err != nil { wwlog.Error("Could not create destination file %s: %s\n", dst, err) return err diff --git a/overlays/host/etc/profile.d/ssh_setup.csh b/overlays/host/etc/profile.d/ssh_setup.csh index 5d810032..8befc753 100644 --- a/overlays/host/etc/profile.d/ssh_setup.csh +++ b/overlays/host/etc/profile.d/ssh_setup.csh @@ -5,12 +5,7 @@ set _UID=`id -u` -if ( $_UID < 500 && $_UID != 0 ) then - exit -endif - - -if ( ! -f "$HOME/.ssh/config" && ! -f "$HOME/.ssh/cluster" ) then +if ( ( $_UID > 500 || $_UID == 0 ) && ( ! -f "$HOME/.ssh/config" && ! -f "$HOME/.ssh/cluster" ) ) then echo "Configuring SSH for cluster access" install -d -m 700 $HOME/.ssh ssh-keygen -t rsa -f $HOME/.ssh/cluster -N '' -C "Warewulf Cluster key" >& /dev/null diff --git a/overlays/host/etc/profile.d/ssh_setup.sh b/overlays/host/etc/profile.d/ssh_setup.sh index c54e46bc..daa1dfb8 100644 --- a/overlays/host/etc/profile.d/ssh_setup.sh +++ b/overlays/host/etc/profile.d/ssh_setup.sh @@ -13,12 +13,7 @@ _UID=`id -u` -if [ $_UID -lt 500 -a $_UID -ne 0 ]; then - exit -fi - - -if [ ! -f "$HOME/.ssh/config" -a ! -f "$HOME/.ssh/cluster" ]; then +if [ $_UID -ge 500 -o $_UID -eq 0 ] && [ ! -f "$HOME/.ssh/config" -a ! -f "$HOME/.ssh/cluster" ]; then echo "Configuring SSH for cluster access" install -d -m 700 $HOME/.ssh ssh-keygen -t rsa -f $HOME/.ssh/cluster -N '' -C "Warewulf Cluster key" > /dev/null 2>&1