|
|
96373c |
From 50d62b6d5ea69e5cad6359dbd1dccb09fcfa1a6b Mon Sep 17 00:00:00 2001
|
|
|
96373c |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
96373c |
Date: Tue, 3 Oct 2017 09:51:53 -0400
|
|
|
96373c |
Subject: [PATCH] Ticket 49320 - Activating already active role returns error
|
|
|
96373c |
16
|
|
|
96373c |
|
|
|
96373c |
Bug Description: ns-activate.pl returns error 16 when trying to activate an
|
|
|
96373c |
already active role.
|
|
|
96373c |
|
|
|
96373c |
Fix Description: Check for error 16 (no such attr), and return error 100.
|
|
|
96373c |
Also added a "redirect"otion to the ldapmod function to
|
|
|
96373c |
hide any errors printed to STDERR, so that the script can
|
|
|
96373c |
display its own error message.
|
|
|
96373c |
|
|
|
96373c |
https://pagure.io/389-ds-base/issue/49320
|
|
|
96373c |
|
|
|
96373c |
Reviewed by: firstyear(Thanks!)
|
|
|
96373c |
|
|
|
96373c |
(cherry picked from commit 406084847f29aa44ffd81de746770aeff6b67c61)
|
|
|
96373c |
---
|
|
|
96373c |
ldap/admin/src/scripts/DSUtil.pm.in | 18 +++++++++++-------
|
|
|
96373c |
ldap/admin/src/scripts/ns-activate.pl.in | 9 ++++++++-
|
|
|
96373c |
2 files changed, 19 insertions(+), 8 deletions(-)
|
|
|
96373c |
|
|
|
96373c |
diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
|
|
|
96373c |
index 805a9b91d..791464d0a 100644
|
|
|
96373c |
--- a/ldap/admin/src/scripts/DSUtil.pm.in
|
|
|
96373c |
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
|
|
|
96373c |
@@ -1447,6 +1447,10 @@ sub ldapmod {
|
|
|
96373c |
close (FILE);
|
|
|
96373c |
}
|
|
|
96373c |
|
|
|
96373c |
+ if ($info{redirect} eq ""){
|
|
|
96373c |
+ $info{redirect} = "> /dev/null";
|
|
|
96373c |
+ }
|
|
|
96373c |
+
|
|
|
96373c |
#
|
|
|
96373c |
# Check the protocol, and reset it if it's invalid
|
|
|
96373c |
#
|
|
|
96373c |
@@ -1470,9 +1474,9 @@ sub ldapmod {
|
|
|
96373c |
print "STARTTLS)\n";
|
|
|
96373c |
}
|
|
|
96373c |
if($info{openldap} eq "yes"){
|
|
|
96373c |
- system "ldapmodify -x -ZZ -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
|
|
|
96373c |
+ system "ldapmodify -x -ZZ -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
|
|
|
96373c |
} else {
|
|
|
96373c |
- system "ldapmodify -ZZZ -P \"$info{certdir}\" -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
|
|
|
96373c |
+ system "ldapmodify -ZZZ -P \"$info{certdir}\" -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
|
|
|
96373c |
}
|
|
|
96373c |
} elsif (($info{security} eq "on" && $info{protocol} eq "") || ($info{security} eq "on" && $info{protocol} =~ m/LDAPS/i) ){
|
|
|
96373c |
#
|
|
|
96373c |
@@ -1482,9 +1486,9 @@ sub ldapmod {
|
|
|
96373c |
print "LDAPS)\n";
|
|
|
96373c |
}
|
|
|
96373c |
if($info{openldap} eq "yes"){
|
|
|
96373c |
- system "ldapmodify -x -H \"ldaps://$info{host}:$info{secure_port}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
|
|
|
96373c |
+ system "ldapmodify -x -H \"ldaps://$info{host}:$info{secure_port}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
|
|
|
96373c |
} else {
|
|
|
96373c |
- system "ldapmodify -Z -P \"$info{certdir}\" -p $info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
|
|
|
96373c |
+ system "ldapmodify -Z -P \"$info{certdir}\" -p $info{secure_port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
|
|
|
96373c |
}
|
|
|
96373c |
} elsif (($info{openldap} eq "yes") && (($info{ldapi} eq "on" && $info{protocol} eq "") || ($info{ldapi} eq "on" && $info{protocol} =~ m/LDAPI/i)) ){
|
|
|
96373c |
#
|
|
|
96373c |
@@ -1499,7 +1503,7 @@ sub ldapmod {
|
|
|
96373c |
if($protocol_error eq "yes"){
|
|
|
96373c |
print "LDAPI)\n";
|
|
|
96373c |
}
|
|
|
96373c |
- system "ldapmodify -x -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
|
|
|
96373c |
+ system "ldapmodify -x -H \"$info{ldapiURL}\" -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
|
|
|
96373c |
}
|
|
|
96373c |
} else {
|
|
|
96373c |
#
|
|
|
96373c |
@@ -1509,9 +1513,9 @@ sub ldapmod {
|
|
|
96373c |
print "LDAP)\n";
|
|
|
96373c |
}
|
|
|
96373c |
if($info{openldap} eq "yes"){
|
|
|
96373c |
- system "ldapmodify -x -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
|
|
|
96373c |
+ system "ldapmodify -x -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
|
|
|
96373c |
} else {
|
|
|
96373c |
- system "ldapmodify -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" > /dev/null";
|
|
|
96373c |
+ system "ldapmodify -h $info{host} -p $info{port} -D \"$info{rootdn}\" -w $myrootdnpw $info{args} -f \"$file\" $info{redirect}";
|
|
|
96373c |
}
|
|
|
96373c |
}
|
|
|
96373c |
unlink ($file);
|
|
|
96373c |
diff --git a/ldap/admin/src/scripts/ns-activate.pl.in b/ldap/admin/src/scripts/ns-activate.pl.in
|
|
|
96373c |
index 5922c9aab..bec19c8e7 100644
|
|
|
96373c |
--- a/ldap/admin/src/scripts/ns-activate.pl.in
|
|
|
96373c |
+++ b/ldap/admin/src/scripts/ns-activate.pl.in
|
|
|
96373c |
@@ -731,11 +731,18 @@ if ( $single == 1 ){
|
|
|
96373c |
}
|
|
|
96373c |
|
|
|
96373c |
$info{args} = "-c";
|
|
|
96373c |
+$info{redirect} = "> /dev/null 2>&1;;
|
|
|
96373c |
DSUtil::ldapmod($record, %info);
|
|
|
96373c |
if( $? != 0 ){
|
|
|
96373c |
debug("delete, $entry\n");
|
|
|
96373c |
$retCode=$?>>8;
|
|
|
96373c |
- exit $retCode;
|
|
|
96373c |
+ if ($retCode == "16") { # Error 16 (no such attr) - already activated
|
|
|
96373c |
+ out("$entry already $state.\n");
|
|
|
96373c |
+ exit 100;
|
|
|
96373c |
+ } else {
|
|
|
96373c |
+ out("Failed to activate $entry, error $retCode\n");
|
|
|
96373c |
+ exit $retCode;
|
|
|
96373c |
+ }
|
|
|
96373c |
}
|
|
|
96373c |
|
|
|
96373c |
out("$entry $state.\n");
|
|
|
96373c |
--
|
|
|
96373c |
2.13.6
|
|
|
96373c |
|