Skip to content

Commit c1e3728

Browse files
committed
packages: fix system test populate sed expression
Motivation: On MacOS, `system-tests` fail to build with this error: ``` [INFO] --- exec:3.1.0:exec (populate) @ system-test --- sed: 1: "s:subject= *\+/\?:/:;s: ...": RE error: repetition-operator operand invalid ``` It would seem that MacOS `sed` does not recognize an escape before `+` as meaning a literal '+'. ``` alberts-mbp:certs arossi$ sed 's:subject= *\+/\?:/:;s:, :/:g' sed: 1: "s:subject= *\+/\?:/:;s: ...": RE error: repetition-operator operand invalid ``` See: https://unix.stackexchange.com/questions/229476/getting-re-error-repetition-operator-operand-invalid-on-osx-sed Modification: This expression occurs twice in the `populate` script. Changing to: ` sed -E -e 's:subject= */?:/:;s:, :/:g;s: = :=:g'` fixes it on MacOS. Linux also seems to accept that syntax as well. This has been factored out into a function. Result: MacOS runs `system-test` again. Target: master Request: 9.1 Request: 9.0 Request: 8.2 Requires-notes: yes Patch: https://rb.dcache.org/r/14100/ Acked-by: Paul Acked-by: Dmitry
1 parent 2a01b13 commit c1e3728

File tree

1 file changed

+7
-2
lines changed
  • packages/system-test/src/main/bin

1 file changed

+7
-2
lines changed

packages/system-test/src/main/bin/populate

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ lib="$(getProperty dcache.paths.share.lib)"
1818

1919
cd @TARGET@/dcache
2020

21+
extract_dn() {
22+
openssl x509 -in $1 -noout -subject -nameopt compat | sed -E -e 's:subject= */?:/:;s:, :/:g;s: = :=:g'
23+
}
24+
2125
build_ca() {
2226
local host_cert_hash old_dn ca_key ca_cert ca_index trust_store ca_serial
2327

@@ -134,7 +138,8 @@ EOF
134138
host_cert_hash=$(openssl x509 -in $ca_cert -noout -subject_hash)
135139
cp "$ca_cert" "$trust_store/$host_cert_hash.0"
136140

137-
old_dn="$(openssl x509 -in $ca_cert -noout -subject -nameopt compat | sed 's:subject= *\+/\?:/:;s:, :/:g')"
141+
old_dn=$(extract_dn "$ca_cert")
142+
138143
cat > "$trust_store/$host_cert_hash.signing_policy" <<EOF
139144
access_id_CA X509 '$old_dn'
140145
pos_rights globus CA:sign
@@ -278,7 +283,7 @@ add_dn_from_file() { # $1 - X.509 pem certificate
278283
return
279284
fi
280285

281-
dn=$(openssl x509 -in "$1" -subject -noout -nameopt compat | sed 's:subject= *\+/\?:/:;s:, :/:g')
286+
dn=$(extract_dn "$1")
282287

283288
rc=0
284289
bin/dcache kpwd dcuserlist "$username" | grep -q "Authentication Record" || rc=$?

0 commit comments

Comments
 (0)