From 17562291f2c38003144db19ea1a7d82481bff3b7 Mon Sep 17 00:00:00 2001 From: Philip Kovacs Date: Nov 16 2017 19:24:37 +0000 Subject: Added patch to enable full relro builds and operation. Added patch to link knl_generic plugin to libnuma if available. Remove the following cray or bluegene-only plugins: job_container/cncu, select/alps, select/bluegene. Rename slurm_setuser to slurm-setuser. Minor corrections to slurm.conf. --- diff --git a/slurm-setuser.in b/slurm-setuser.in new file mode 100644 index 0000000..ae7e6c2 --- /dev/null +++ b/slurm-setuser.in @@ -0,0 +1,229 @@ +#!/bin/bash +# +# Copyright (c) 2017, Philip Kovacs +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +prog=`basename $0` +user=root +group=root +yesno=no + +red='\033[0;31m' +green='\033[0;32m' +nc='\033[0m' +pass="${green}[*]${nc}" +fail="${red}[!]${nc}" +ask="[?]" + +# the rpm spec configures these directory variables +dir_conf="%{_sysconfdir}/%{name}" +dir_log="%{_var}/log/%{name}" +dir_run="%{_rundir}/%{name}" +dir_spool="%{_var}/spool/%{name}" +dir_tmpfiles_d="%{_tmpfilesdir}" + +file_slurm_conf="${dir_conf}/slurm.conf" +file_slurmdbd_conf="${dir_conf}/slurmdbd.conf" +file_tmpfiles_d_conf="${dir_tmpfiles_d}/slurm.conf" + +function usage () +{ + echo -e "Sets the slurm installation on this node to run as the specified user and group\n" + echo "Usage: $prog [-u ] [-g ] [-h] [-y]" + echo " -u : the slurm file owner and SlurmUser ($user)" + echo " -g : the slurm file group ($group)" + echo " -y : answer yes to all questions ($yesno)" + echo " -h : print help" +} + +function answer () +{ + while true + do + if [ "${yesno}" = "yes" ]; then + echo -e "${ask} $1 [${yesno}]" + __answer="yes" + break; + fi + + echo -e -n "${ask} " + read -e -p "$1 [${yesno}] " yn + case $yn in + "") __answer=$yesno + break;; + [yY]*) __answer="yes" + break;; + [nN]*) __answer="no" + break;; + *) + echo "Please answer yes or no";; + esac + done +} + +# +# Parse options +# +while getopts "u:g:yh" opt +do + case "$opt" in + h) + usage + exit 2;; + u) + user=$OPTARG;; + g) + group=$OPTARG;; + y) + yesno=yes;; + *) + echo "" + usage + exit 2;; + esac +done + +# +# Run this script only as root +# +if [ $UID -eq 0 ]; then + echo -e "${pass} running as root... good" +else + echo -e "${fail} $prog must be run as root." + exit 1 +fi + +# +# Validate the user and group +# +valid_user="`getent passwd $user || :`" +if [ -n "$valid_user" ]; then + echo -e "${pass} found user $user... good" +else + echo -e "${fail} the specified user was not found... ${user}" + exit 2 +fi +valid_group="`getent group $group || :`" +if [ -n "$valid_group" ]; then + echo -e "${pass} found group $group... good" +else + echo -e "${fail} the specified group was not found... ${group}" + exit 2 +fi + +# +# Slurm services must not be running +# +slurmctld_running_pid="`ps -e | grep slurmctld | grep -v grep | awk '{print $1}'`" +if [ -z "$slurmctld_running_pid" ]; then + echo -e "${pass} slurmctld is not running... good" +else + echo -e "${fail} slurmctld is running... stop it with [systemctl stop slurmctld]" + exit 2 +fi +slurmd_running_pid="`ps -e | grep slurmd | grep -v grep | awk '{print $1}'`" +if [ -z "$slurmd_running_pid" ]; then + echo -e "${pass} slurmd is not running... good" +else + echo -e "${fail} slurmd is running... stop it with [systemctl stop slurmd]" + exit 2 +fi +slurmdbd_running_pid="`ps -e | grep slurmdbd | grep -v grep | awk '{print $1}'`" +if [ -z "$slurmdbd_running_pid" ]; then + echo -e "${pass} slurmdbd is not running... good" +else + echo -e "${fail} slurmdbd is running... stop it with [systemctl stop slurmdbd]" + exit 2 +fi + +# +# Update SlurmUser in the slurm configs +# +for file in "$file_slurm_conf" "$file_slurmdbd_conf" +do + if [ -f "$file" ]; then + answer "update SlurmUser in $file ?" + if [ "$__answer" = "yes" ]; then + sed -i "s|^SlurmUser=.*|SlurmUser=${user}|g" $file + if [ $? -eq 0 ]; then + echo -e "${pass} $file updated successfully" + else + echo -e "${fail} error updating $file" + exit 1 + fi + fi + fi +done + +# +# Update ownership of slurm directories that must be owned by the slurm user +# +for dir in "$dir_log" "$dir_run" "$dir_spool" "$dir_spool/ctld" +do + if [ -d "$dir" ]; then + answer "update ownership of $dir ?" + if [ "$__answer" = "yes" ]; then + chown ${user}:${group} $dir + if [ $? -eq 0 ]; then + echo -e "${pass} $dir updated successfully" + else + echo -e "${fail} error updating $dir" + exit 1 + fi + fi + fi +done + +# +# Update ownership of slurmctld spool files which are owned by the slurm user +# +if [ -d "${dir_spool}/ctld" ]; then + answer "update ownership of files in ${dir_spool}/ctld ?" + if [ "$__answer" = "yes" ]; then + if [ $? -eq 0 ]; then + find ${dir_spool}/ctld -mindepth 1 -exec chown ${user}:${group} {} \; + echo -e "${pass} ${dir_spool}/ctld files updated successfully" + else + echo -e "${fail} error updating ${dir_spool}/ctld files" + exit 1 + fi + fi +fi + +# +# Update the tmpfiles.d config file to the new slurm user +# +if [ -f "$file_tmpfiles_d_conf" ]; then + answer "update tmpfiles.d config $file_tmpfiles_d_conf ?" + if [ "$__answer" = "yes" ]; then + sed -i "s|0755 \(.*\) -$|0755 ${user} ${group} -|g" $file_tmpfiles_d_conf + if [ $? -eq 0 ]; then + echo -e "${pass} $file_tmpfiles_d_conf updated successfully" + else + echo -e "${fail} error updating $file_tmpfiles_d_conf" + exit 1 + fi + fi +fi + +exit 0 diff --git a/slurm.conf b/slurm.conf index cb02c0d..28bd7a8 100644 --- a/slurm.conf +++ b/slurm.conf @@ -23,11 +23,11 @@ CryptoType=crypto/munge #JobCredentialPublicCertificate= #JobFileAppend=0 #JobRequeue=1 -#JobSubmitPlugins=1 +#JobSubmitPlugins= #KillOnBadExit=0 #LaunchType=launch/slurm #Licenses=foo*4,bar -#MailProg=/bin/mail +#MailProg=/bin/true #MaxJobCount=5000 #MaxStepCount=40000 #MaxTasksPerNode=128 diff --git a/slurm.spec b/slurm.spec index facd9cc..017b35a 100644 --- a/slurm.spec +++ b/slurm.spec @@ -26,7 +26,7 @@ Name: slurm Version: 17.02.9 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Simple Linux Utility for Resource Management License: GPLv2 and BSD URL: https://slurm.schedmd.com/ @@ -35,18 +35,22 @@ Source1: slurm.conf Source2: slurmdbd.conf Source3: slurm-sview.desktop Source4: slurm-128x128.png -Source5: slurm_setuser.in +Source5: slurm-setuser.in + +# upstream bug #2443: enable full relro operation +Patch0: slurm_weak_symbols.patch + +# upstream bug #4362: link knl_generic plugin to libnuma if available +Patch1: slurm_knl_numa.patch # build-related patches -Patch1: slurm_perlapi_rpaths.patch -Patch2: slurm_html_doc_path.patch -Patch3: slurm_doc_fix.patch +Patch10: slurm_perlapi_rpaths.patch +Patch11: slurm_html_doc_path.patch +Patch12: slurm_doc_fix.patch # Fedora-related patches -Patch4: slurm_service_files.patch +Patch20: slurm_service_files.patch -BuildRequires: autoconf -BuildRequires: automake BuildRequires: pkgconfig(gtk+-2.0) BuildRequires: hdf5-devel BuildRequires: pkgconfig(hwloc) @@ -70,6 +74,8 @@ BuildRequires: libibumad-devel BuildRequires: numactl-devel %endif +BuildRequires: autoconf +BuildRequires: automake BuildRequires: desktop-file-utils BuildRequires: gcc BuildRequires: perl-ExtUtils-MakeMaker @@ -211,10 +217,12 @@ Torque wrapper scripts used for helping migrate from Torque/PBS to Slurm. %prep %setup -q -n %{name}-%{version} +%patch0 -p1 %patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch20 -p1 cp %SOURCE1 etc/slurm.conf cp %SOURCE1 etc/slurm.conf.example cp %SOURCE2 etc/slurmdbd.conf @@ -224,17 +232,12 @@ mkdir -p share/icons/hicolor/128x128/apps cp %SOURCE3 share/applications/%{name}-sview.desktop cp %SOURCE4 share/icons/hicolor/128x128/apps/%{name}.png mkdir -p extras -cp %SOURCE5 extras/slurm_setuser.in +cp %SOURCE5 extras/slurm-setuser.in %build %{__aclocal} -I auxdir %{__autoconf} %{__automake} --no-force -# upstream bug #2443. need to force lazy linkage since plugins contain -# undefined symbols not used in every context, i.e. slurmctld vs slurmd. -CFLAGS="$RPM_OPT_FLAGS -Wl,-z,lazy" -CXXFLAGS="$RPM_OPT_FLAGS -Wl,-z,lazy" -# --enable-debug (auxdir/x_ac_debug.m4) breaks fortification (-O0) %configure \ --prefix=%{_prefix} \ --sysconfdir=%{_sysconfdir}/%{name} \ @@ -253,14 +256,14 @@ CXXFLAGS="$RPM_OPT_FLAGS -Wl,-z,lazy" # patch libtool to remove rpaths sed -i 's|^hardcode_into_libs=.*|hardcode_into_libs=no|g' libtool -# configure the extras/slurm_setuser script +# configure the extras/slurm-setuser script sed -r ' s|^dir_conf=.*|dir_conf="%{_sysconfdir}/%{name}"|g; s|^dir_log=.*|dir_log="%{_var}/log/%{name}"|g; s|^dir_run=.*|dir_run="%{_rundir}/%{name}"|g; s|^dir_spool=.*|dir_spool="%{_var}/spool/%{name}"|g; s|^dir_tmpfiles_d=.*|dir_tmpfiles_d="%{_tmpfilesdir}"|g;' \ - extras/slurm_setuser.in > extras/slurm_setuser + extras/slurm-setuser.in > extras/slurm-setuser # build base packages %make_build V=1 @@ -349,9 +352,9 @@ install -d -m 0755 %{buildroot}%{_datadir}/icons/hicolor/128x128/apps install -m 0644 share/icons/hicolor/128x128/apps/%{name}.png \ %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/%{name}.png -# install the extras/slurm_setuser script -install -m 0755 extras/slurm_setuser \ - %{buildroot}%{_bindir}/slurm_setuser +# install the extras/slurm-setuser script +install -m 0755 extras/slurm-setuser \ + %{buildroot}%{_bindir}/slurm-setuser install -m 0755 contribs/sjstat %{buildroot}%{_bindir}/sjstat @@ -382,6 +385,7 @@ rm -f %{buildroot}%{_libdir}/%{name}/job_submit_partition.so rm -f %{buildroot}%{_libdir}/%{name}/libsched_if.so rm -f %{buildroot}%{_libdir}/%{name}/libsched_if64.so rm -f %{buildroot}%{_libdir}/%{name}/runjob_plugin.so +rm -f %{buildroot}%{_libdir}/%{name}/select_bluegene.so rm -f %{buildroot}%{_mandir}/man5/bluegene* rm -f %{buildroot}%{_sbindir}/sfree rm -f %{buildroot}%{_sbindir}/slurm_epilog @@ -389,7 +393,9 @@ rm -f %{buildroot}%{_sbindir}/slurm_prolog # remove cray files rm -f %{buildroot}%{_libdir}/%{name}/acct_gather_energy_cray.so rm -f %{buildroot}%{_libdir}/%{name}/core_spec_cray.so +rm -f %{buildroot}%{_libdir}/%{name}/job_container_cncu.so rm -f %{buildroot}%{_libdir}/%{name}/job_submit_cray.so +rm -f %{buildroot}%{_libdir}/%{name}/select_alps.so rm -f %{buildroot}%{_libdir}/%{name}/select_cray.so rm -f %{buildroot}%{_libdir}/%{name}/switch_cray.so rm -f %{buildroot}%{_libdir}/%{name}/task_cray.so @@ -428,7 +434,7 @@ rm -f %{buildroot}%{perl_archlib}/perllocal.pod %{_bindir}/{sacct,sacctmgr,salloc,sattach,sbatch,sbcast} %{_bindir}/{scancel,scontrol,sdiag,sh5util,sinfo,sprio} %{_bindir}/{squeue,sreport,srun,sshare,sstat,strigger} -%{_bindir}/slurm_setuser +%{_bindir}/slurm-setuser %{_unitdir}/slurmctld.service %{_unitdir}/slurmd.service %{_tmpfilesdir}/slurm.conf @@ -527,7 +533,7 @@ rm -f %{buildroot}%{perl_archlib}/perllocal.pod %{_libdir}/%{name}/crypto_openssl.so %{_libdir}/%{name}/ext_sensors_none.so %{_libdir}/%{name}/gres_{gpu,mic,nic}.so -%{_libdir}/%{name}/job_container_{cncu,none}.so +%{_libdir}/%{name}/job_container_none.so %{_libdir}/%{name}/job_submit_all_partitions.so %{_libdir}/%{name}/job_submit_require_timelimit.so %{_libdir}/%{name}/job_submit_throttle.so @@ -546,7 +552,7 @@ rm -f %{buildroot}%{perl_archlib}/perllocal.pod %{_libdir}/%{name}/proctrack_{cgroup,linuxproc,pgid}.so %{_libdir}/%{name}/route_{default,topology}.so %{_libdir}/%{name}/sched_{backfill,builtin,hold}.so -%{_libdir}/%{name}/select_{alps,bluegene,cons_res,linear,serial}.so +%{_libdir}/%{name}/select_{cons_res,linear,serial}.so %{_libdir}/%{name}/slurmctld_nonstop.so %{_libdir}/%{name}/switch_{generic,none}.so %{_libdir}/%{name}/task_{affinity,cgroup,none}.so @@ -614,7 +620,7 @@ rm -f %{buildroot}%{perl_archlib}/perllocal.pod %{_sysconfdir}/%{name}/slurmdbd.conf.example %dir %{_rundir}/%{name} %ghost %{_rundir}/%{name}/slurmdbd.pid -%{_bindir}/slurm_setuser +%{_bindir}/slurm-setuser %{_unitdir}/slurmdbd.service %{_tmpfilesdir}/slurm.conf %{_sbindir}/slurmdbd @@ -746,6 +752,14 @@ fi %systemd_postun_with_restart slurmdbd.service %changelog +* Thu Nov 16 2017 Philip Kovacs - 17.02.9-3 +- Added patch to enable full relro builds and operation. +- Added patch to link knl_generic plugin to libnuma if available. +- Remove the following cray or bluegene-only plugins: +- job_container/cncu, select/alps, select/bluegene. +- Rename slurm_setuser to slurm-setuser. +- Minor corrections to slurm.conf. + * Wed Nov 1 2017 Philip Kovacs - 17.02.9-2 - Correct desktop categories for rpmgrill.desktop-lint. diff --git a/slurm_doc_fix.patch b/slurm_doc_fix.patch index f835a53..ae4a4da 100644 --- a/slurm_doc_fix.patch +++ b/slurm_doc_fix.patch @@ -1,5 +1,5 @@ ---- slurm-17.02.9/doc/man/man5/burst_buffer.conf.5.old 2017-08-15 23:22:24.333180212 -0400 -+++ slurm-17.02.9/doc/man/man5/burst_buffer.conf.5 2017-08-15 23:23:45.224298397 -0400 +--- a/doc/man/man5/burst_buffer.conf.5 2017-08-15 23:22:24.333180212 -0400 ++++ b/doc/man/man5/burst_buffer.conf.5 2017-08-15 23:23:45.224298397 -0400 @@ -31,18 +31,18 @@ \fBAllowUsers\fR Comma separated list of user names and/or IDs permitted to use burst buffers. diff --git a/slurm_html_doc_path.patch b/slurm_html_doc_path.patch index 9ea8dcc..04c1475 100644 --- a/slurm_html_doc_path.patch +++ b/slurm_html_doc_path.patch @@ -1,5 +1,5 @@ ---- slurm-17.02.9/doc/html/Makefile.am.old 2017-10-25 15:55:38.622808585 -0400 -+++ slurm-17.02.9/doc/html/Makefile.am 2017-10-25 15:56:07.236582868 -0400 +--- a/doc/html/Makefile.am 2017-10-25 15:55:38.622808585 -0400 ++++ b/doc/html/Makefile.am 2017-10-25 15:56:07.236582868 -0400 @@ -1,5 +1,5 @@ -htmldir = ${datadir}/doc/${PACKAGE}-${SLURM_VERSION_STRING}/html diff --git a/slurm_knl_numa.patch b/slurm_knl_numa.patch new file mode 100644 index 0000000..d13a683 --- /dev/null +++ b/slurm_knl_numa.patch @@ -0,0 +1,13 @@ +diff --git a/src/plugins/node_features/knl_generic/Makefile.am b/src/plugins/node_features/knl_generic/Makefile.am +index 11da24c075..4633e2de46 100644 +--- a/src/plugins/node_features/knl_generic/Makefile.am ++++ b/src/plugins/node_features/knl_generic/Makefile.am +@@ -8,7 +8,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src/common + + pkglib_LTLIBRARIES = node_features_knl_generic.la + node_features_knl_generic_la_SOURCES = node_features_knl_generic.c +-node_features_knl_generic_la_LDFLAGS = $(SO_LDFLAGS) $(PLUGIN_FLAGS) ++node_features_knl_generic_la_LDFLAGS = $(SO_LDFLAGS) $(NUMA_LIBS) $(PLUGIN_FLAGS) + + force: + $(node_features_knl_generic_la_LIBADD) : force diff --git a/slurm_perlapi_rpaths.patch b/slurm_perlapi_rpaths.patch index 0caf61a..0da934b 100644 --- a/slurm_perlapi_rpaths.patch +++ b/slurm_perlapi_rpaths.patch @@ -1,5 +1,5 @@ ---- slurm-17.02.9/contribs/perlapi/libslurm/perl/Makefile.PL.in.old 2016-11-08 15:11:32.000000000 -0500 -+++ slurm-17.02.9/contribs/perlapi/libslurm/perl/Makefile.PL.in 2017-08-17 03:06:27.363688978 -0400 +--- a/contribs/perlapi/libslurm/perl/Makefile.PL.in 2016-11-08 15:11:32.000000000 -0500 ++++ b/contribs/perlapi/libslurm/perl/Makefile.PL.in 2017-08-17 03:06:27.363688978 -0400 @@ -77,7 +77,7 @@ # AIX has problems with not always having the correct # flags so we have to add some :) @@ -9,8 +9,8 @@ $other_ld_flags = " -brtl -G -bnoentry -bgcbypass:1000 -bexpfull" if $os =~ "aix"; ---- slurm-17.02.9/contribs/perlapi/libslurmdb/perl/Makefile.PL.in.orig 2017-08-17 03:37:39.689054161 -0400 -+++ slurm-17.02.9/contribs/perlapi/libslurmdb/perl/Makefile.PL.in 2017-08-17 03:38:07.305780718 -0400 +--- a/contribs/perlapi/libslurmdb/perl/Makefile.PL.in 2017-08-17 03:37:39.689054161 -0400 ++++ b/contribs/perlapi/libslurmdb/perl/Makefile.PL.in 2017-08-17 03:38:07.305780718 -0400 @@ -76,7 +76,7 @@ # AIX has problems with not always having the correct # flags so we have to add some :) diff --git a/slurm_service_files.patch b/slurm_service_files.patch index 61bf0ac..a164ef4 100644 --- a/slurm_service_files.patch +++ b/slurm_service_files.patch @@ -1,5 +1,5 @@ ---- slurm-17.02.9/etc/slurmctld.service.in.old 2017-08-14 13:48:43.000000000 -0400 -+++ slurm-17.02.9/etc/slurmctld.service.in 2017-08-21 13:35:26.472209176 -0400 +--- a/etc/slurmctld.service.in 2017-08-14 13:48:43.000000000 -0400 ++++ b/etc/slurmctld.service.in 2017-08-21 13:35:26.472209176 -0400 @@ -8,7 +8,7 @@ EnvironmentFile=-/etc/sysconfig/slurmctld ExecStart=@sbindir@/slurmctld $SLURMCTLD_OPTIONS @@ -9,8 +9,8 @@ [Install] WantedBy=multi-user.target ---- slurm-17.02.9/etc/slurmd.service.in.old 2017-08-14 13:48:43.000000000 -0400 -+++ slurm-17.02.9/etc/slurmd.service.in 2017-08-21 14:45:23.485061312 -0400 +--- a/etc/slurmd.service.in 2017-08-14 13:48:43.000000000 -0400 ++++ b/etc/slurmd.service.in 2017-08-21 14:45:23.485061312 -0400 @@ -8,7 +8,7 @@ EnvironmentFile=-/etc/sysconfig/slurmd ExecStart=@sbindir@/slurmd $SLURMD_OPTIONS @@ -20,8 +20,8 @@ KillMode=process LimitNOFILE=51200 LimitMEMLOCK=infinity ---- slurm-17.02.9/etc/slurmdbd.service.in.old 2017-08-14 13:48:43.000000000 -0400 -+++ slurm-17.02.9/etc/slurmdbd.service.in 2017-08-21 14:47:56.134071820 -0400 +--- a/etc/slurmdbd.service.in 2017-08-14 13:48:43.000000000 -0400 ++++ b/etc/slurmdbd.service.in 2017-08-21 14:47:56.134071820 -0400 @@ -8,7 +8,7 @@ EnvironmentFile=-/etc/sysconfig/slurmdbd ExecStart=@sbindir@/slurmdbd $SLURMDBD_OPTIONS diff --git a/slurm_setuser.in b/slurm_setuser.in deleted file mode 100644 index ae7e6c2..0000000 --- a/slurm_setuser.in +++ /dev/null @@ -1,229 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2017, Philip Kovacs -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -prog=`basename $0` -user=root -group=root -yesno=no - -red='\033[0;31m' -green='\033[0;32m' -nc='\033[0m' -pass="${green}[*]${nc}" -fail="${red}[!]${nc}" -ask="[?]" - -# the rpm spec configures these directory variables -dir_conf="%{_sysconfdir}/%{name}" -dir_log="%{_var}/log/%{name}" -dir_run="%{_rundir}/%{name}" -dir_spool="%{_var}/spool/%{name}" -dir_tmpfiles_d="%{_tmpfilesdir}" - -file_slurm_conf="${dir_conf}/slurm.conf" -file_slurmdbd_conf="${dir_conf}/slurmdbd.conf" -file_tmpfiles_d_conf="${dir_tmpfiles_d}/slurm.conf" - -function usage () -{ - echo -e "Sets the slurm installation on this node to run as the specified user and group\n" - echo "Usage: $prog [-u ] [-g ] [-h] [-y]" - echo " -u : the slurm file owner and SlurmUser ($user)" - echo " -g : the slurm file group ($group)" - echo " -y : answer yes to all questions ($yesno)" - echo " -h : print help" -} - -function answer () -{ - while true - do - if [ "${yesno}" = "yes" ]; then - echo -e "${ask} $1 [${yesno}]" - __answer="yes" - break; - fi - - echo -e -n "${ask} " - read -e -p "$1 [${yesno}] " yn - case $yn in - "") __answer=$yesno - break;; - [yY]*) __answer="yes" - break;; - [nN]*) __answer="no" - break;; - *) - echo "Please answer yes or no";; - esac - done -} - -# -# Parse options -# -while getopts "u:g:yh" opt -do - case "$opt" in - h) - usage - exit 2;; - u) - user=$OPTARG;; - g) - group=$OPTARG;; - y) - yesno=yes;; - *) - echo "" - usage - exit 2;; - esac -done - -# -# Run this script only as root -# -if [ $UID -eq 0 ]; then - echo -e "${pass} running as root... good" -else - echo -e "${fail} $prog must be run as root." - exit 1 -fi - -# -# Validate the user and group -# -valid_user="`getent passwd $user || :`" -if [ -n "$valid_user" ]; then - echo -e "${pass} found user $user... good" -else - echo -e "${fail} the specified user was not found... ${user}" - exit 2 -fi -valid_group="`getent group $group || :`" -if [ -n "$valid_group" ]; then - echo -e "${pass} found group $group... good" -else - echo -e "${fail} the specified group was not found... ${group}" - exit 2 -fi - -# -# Slurm services must not be running -# -slurmctld_running_pid="`ps -e | grep slurmctld | grep -v grep | awk '{print $1}'`" -if [ -z "$slurmctld_running_pid" ]; then - echo -e "${pass} slurmctld is not running... good" -else - echo -e "${fail} slurmctld is running... stop it with [systemctl stop slurmctld]" - exit 2 -fi -slurmd_running_pid="`ps -e | grep slurmd | grep -v grep | awk '{print $1}'`" -if [ -z "$slurmd_running_pid" ]; then - echo -e "${pass} slurmd is not running... good" -else - echo -e "${fail} slurmd is running... stop it with [systemctl stop slurmd]" - exit 2 -fi -slurmdbd_running_pid="`ps -e | grep slurmdbd | grep -v grep | awk '{print $1}'`" -if [ -z "$slurmdbd_running_pid" ]; then - echo -e "${pass} slurmdbd is not running... good" -else - echo -e "${fail} slurmdbd is running... stop it with [systemctl stop slurmdbd]" - exit 2 -fi - -# -# Update SlurmUser in the slurm configs -# -for file in "$file_slurm_conf" "$file_slurmdbd_conf" -do - if [ -f "$file" ]; then - answer "update SlurmUser in $file ?" - if [ "$__answer" = "yes" ]; then - sed -i "s|^SlurmUser=.*|SlurmUser=${user}|g" $file - if [ $? -eq 0 ]; then - echo -e "${pass} $file updated successfully" - else - echo -e "${fail} error updating $file" - exit 1 - fi - fi - fi -done - -# -# Update ownership of slurm directories that must be owned by the slurm user -# -for dir in "$dir_log" "$dir_run" "$dir_spool" "$dir_spool/ctld" -do - if [ -d "$dir" ]; then - answer "update ownership of $dir ?" - if [ "$__answer" = "yes" ]; then - chown ${user}:${group} $dir - if [ $? -eq 0 ]; then - echo -e "${pass} $dir updated successfully" - else - echo -e "${fail} error updating $dir" - exit 1 - fi - fi - fi -done - -# -# Update ownership of slurmctld spool files which are owned by the slurm user -# -if [ -d "${dir_spool}/ctld" ]; then - answer "update ownership of files in ${dir_spool}/ctld ?" - if [ "$__answer" = "yes" ]; then - if [ $? -eq 0 ]; then - find ${dir_spool}/ctld -mindepth 1 -exec chown ${user}:${group} {} \; - echo -e "${pass} ${dir_spool}/ctld files updated successfully" - else - echo -e "${fail} error updating ${dir_spool}/ctld files" - exit 1 - fi - fi -fi - -# -# Update the tmpfiles.d config file to the new slurm user -# -if [ -f "$file_tmpfiles_d_conf" ]; then - answer "update tmpfiles.d config $file_tmpfiles_d_conf ?" - if [ "$__answer" = "yes" ]; then - sed -i "s|0755 \(.*\) -$|0755 ${user} ${group} -|g" $file_tmpfiles_d_conf - if [ $? -eq 0 ]; then - echo -e "${pass} $file_tmpfiles_d_conf updated successfully" - else - echo -e "${fail} error updating $file_tmpfiles_d_conf" - exit 1 - fi - fi -fi - -exit 0 diff --git a/slurm_weak_symbols.patch b/slurm_weak_symbols.patch new file mode 100644 index 0000000..02507e2 --- /dev/null +++ b/slurm_weak_symbols.patch @@ -0,0 +1,153 @@ +diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c +index ca0341c1eb..08d7baaa61 100644 +--- a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c ++++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c +@@ -60,6 +60,15 @@ + + #define BUFFER_SIZE 4096 + ++/* Declare these functions as weak in order to support full relro builds. */ ++#if defined(__GNUC__) && defined(__ELF__) ++/* TEST_CASE: sacct vs slurmctld */ ++void build_array_str(struct job_record *job_ptr) __attribute__((weak)); ++struct job_record *find_job_record(uint32_t job_id) __attribute__((weak)); ++void lock_slurmctld (slurmctld_lock_t lock_levels) __attribute__((weak)); ++void unlock_slurmctld (slurmctld_lock_t lock_levels) __attribute__((weak)); ++#endif ++ + /* These are defined here so when we link with something other than + * the slurmctld we will have these symbols defined. They will get + * overwritten when linking with the slurmctld. +diff --git a/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup.h b/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup.h +index 33f9bcb05e..7bbd99f93d 100644 +--- a/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup.h ++++ b/src/plugins/jobacct_gather/cgroup/jobacct_gather_cgroup.h +@@ -39,6 +39,9 @@ + * Copyright (C) 2002 The Regents of the University of California. + \*****************************************************************************/ + ++#ifndef __JOBACCT_GATHER_CGROUP_H__ ++#define __JOBACCT_GATHER_CGROUP_H__ ++ + #include "src/common/slurm_jobacct_gather.h" + #include "src/common/xcgroup_read_config.h" + #include "src/slurmd/common/xcgroup.h" +@@ -76,3 +79,31 @@ extern int jobacct_gather_cgroup_memory_attach_task( + /* pid_t pid, jobacct_id_t *jobacct_id); */ + + extern char* jobacct_cgroup_create_slurm_cg (xcgroup_ns_t* ns); ++ ++/* Declare these functions as weak in order to support full relro builds. */ ++#if defined(__GNUC__) && defined(__ELF__) ++/* TEST_CASE: slurmctld vs slurmd */ ++int xcgroup_add_pids(xcgroup_t* cg, pid_t* pids, int npids) ++ __attribute__((weak)); ++int xcgroup_create(xcgroup_ns_t* cgns, xcgroup_t* cg, ++ char* uri, uid_t uid, gid_t gid) __attribute__((weak)); ++int xcgroup_delete(xcgroup_t* cg) __attribute__((weak)); ++void xcgroup_destroy(xcgroup_t* cg) __attribute__((weak)); ++int xcgroup_get_param(xcgroup_t* cg, char* param, char **content, ++ size_t *csize) __attribute__((weak)); ++int xcgroup_ns_create(slurm_cgroup_conf_t *conf, ++ xcgroup_ns_t* cgns, char* mnt_args, char* subsys) ++ __attribute__((weak)); ++int xcgroup_instantiate(xcgroup_t* cg) __attribute__((weak)); ++int xcgroup_lock(xcgroup_t* cg) __attribute__((weak)); ++void xcgroup_ns_destroy(xcgroup_ns_t* cgns) __attribute__((weak)); ++int xcgroup_set_param(xcgroup_t* cg, char* parameter, char* content) ++ __attribute__((weak)); ++int xcgroup_set_uint32_param(xcgroup_t* cg, char* parameter, uint32_t value) ++ __attribute__((weak)); ++int xcgroup_unlock(xcgroup_t* cg) __attribute__((weak)); ++int xcpuinfo_fini(void) __attribute__((weak)); ++int xcpuinfo_init(void) __attribute__((weak)); ++#endif ++ ++#endif /* __JOBACCT_GATHER_CGROUP_H__ */ +diff --git a/src/plugins/jobacct_gather/common/common_jag.h b/src/plugins/jobacct_gather/common/common_jag.h +index eff761638e..6a28a40af2 100644 +--- a/src/plugins/jobacct_gather/common/common_jag.h ++++ b/src/plugins/jobacct_gather/common/common_jag.h +@@ -74,4 +74,11 @@ extern void jag_common_poll_data( + List task_list, bool pgid_plugin, uint64_t cont_id, + jag_callbacks_t *callbacks, bool profile); + ++/* Declare these functions as weak in order to support full relro builds. */ ++#if defined(__GNUC__) && defined(__ELF__) ++/* TEST_CASE: slurmctld vs slurmd */ ++int proctrack_g_get_pids(uint64_t cont_id, pid_t **pids, int *npids) ++ __attribute__((weak)); ++#endif ++ + #endif +diff --git a/src/plugins/node_features/knl_generic/node_features_knl_generic.c b/src/plugins/node_features/knl_generic/node_features_knl_generic.c +index f87a685bfc..fb6b879896 100644 +--- a/src/plugins/node_features/knl_generic/node_features_knl_generic.c ++++ b/src/plugins/node_features/knl_generic/node_features_knl_generic.c +@@ -113,6 +113,12 @@ + #define DEFAULT_MCDRAM_SIZE ((uint64_t) 16 * 1024 * 1024 * 1024) + #endif + ++/* Declare these functions as weak in order to support full relro builds. */ ++#if defined(__GNUC__) && defined(__ELF__) ++/* TEST_CASE: slurmctld vs slurmd */ ++int ume_notify(void) __attribute__((weak)); ++#endif ++ + /* These are defined here so when we link with something other than + * the slurmctld we will have these symbols defined. They will get + * overwritten when linking with the slurmctld. +diff --git a/src/plugins/select/cons_res/select_cons_res.h b/src/plugins/select/cons_res/select_cons_res.h +index 0038d1c075..356a17950c 100644 +--- a/src/plugins/select/cons_res/select_cons_res.h ++++ b/src/plugins/select/cons_res/select_cons_res.h +@@ -122,4 +122,15 @@ extern void cr_sort_part_rows(struct part_res_record *p_ptr); + extern uint32_t cr_get_coremap_offset(uint32_t node_index); + extern int cr_cpus_per_core(struct job_details *details, int node_inx); + ++/* Declare these functions as weak in order to support full relro builds. */ ++#if defined(__GNUC__) && defined(__ELF__) ++/* TEST_CASE: slurmd vs srun */ ++int drain_nodes(char *nodes, char *reason, uint32_t reason_uid) ++ __attribute__((weak)); ++uint32_t powercap_get_cluster_current_cap(void) __attribute__((weak)); ++uint16_t slurm_job_preempt_mode(struct job_record *job_ptr) ++ __attribute__((weak)); ++int which_power_layout(void) __attribute__((weak)); ++#endif ++ + #endif /* !_CONS_RES_H */ +diff --git a/src/plugins/select/linear/select_linear.h b/src/plugins/select/linear/select_linear.h +index a9b3bd2bf3..f06f580ccc 100644 +--- a/src/plugins/select/linear/select_linear.h ++++ b/src/plugins/select/linear/select_linear.h +@@ -83,4 +83,11 @@ struct cr_record { + uint16_t tot_job_len; /* length of tot_job_ids array */ + }; + ++/* Declare these functions as weak in order to support full relro builds. */ ++#if defined(__GNUC__) && defined(__ELF__) ++/* TEST_CASE: slurmd vs srun */ ++uint16_t slurm_job_preempt_mode(struct job_record *job_ptr) ++ __attribute__((weak)); ++#endif ++ + #endif /* !_SELECT_LINEAR_H */ +diff --git a/src/plugins/select/serial/select_serial.h b/src/plugins/select/serial/select_serial.h +index e88c49850b..7bea876bd1 100644 +--- a/src/plugins/select/serial/select_serial.h ++++ b/src/plugins/select/serial/select_serial.h +@@ -111,4 +111,13 @@ extern struct node_use_record *select_node_usage; + extern void cr_sort_part_rows(struct part_res_record *p_ptr); + extern uint32_t cr_get_coremap_offset(uint32_t node_index); + ++/* Declare these functions as weak in order to support full relro builds. */ ++#if defined(__GNUC__) && defined(__ELF__) ++/* TEST_CASE: slurmd vs srun */ ++int drain_nodes(char *nodes, char *reason, uint32_t reason_uid) ++ __attribute__((weak)); ++uint16_t slurm_job_preempt_mode(struct job_record *job_ptr) ++ __attribute__((weak)); ++#endif ++ + #endif /* !_SELECT_SERIAL_H */