Like this? (There is a pre-existing check that $1 must exist)

diff --git a/utilities/ovs-pki.in b/utilities/ovs-pki.in
index 89af405..6081a5e 100755
--- a/utilities/ovs-pki.in
+++ b/utilities/ovs-pki.in
@@ -461,9 +461,18 @@ sign_request() {
     must_not_exist "$2"
     pkidir_must_exist

+    case "$1" in
+        "/"*)
+            request_file="$1"
+            ;;
+        *)
+            request_file="`pwd`/$1"
+            ;;
+    esac
+
     (cd "$pkidir/${type}ca" &&
-     openssl ca -config ca.cnf -batch -in /dev/stdin) \
-        < "$1" > "$2.tmp$$" 2>&3
+     openssl ca -config ca.cnf -batch -in "$request_file") \
+        > "$2.tmp$$" 2>&3
     mv "$2.tmp$$" "$2"
 }

On Wed, May 14, 2014 at 3:46 PM, Ben Pfaff <b...@nicira.com> wrote:
> I would use a shell case statement. It should be much cleaner.
>
> On May 14, 2014 3:45 PM, "Gurucharan Shetty" <shet...@nicira.com> wrote:
>>
>> How about making the following assumption?
>>
>> diff --git a/utilities/ovs-pki.in b/utilities/ovs-pki.in
>> index 7f56b4e..417fdf4 100755
>> --- a/utilities/ovs-pki.in
>> +++ b/utilities/ovs-pki.in
>> @@ -461,7 +461,12 @@ sign_request() {
>>      must_not_exist "$2"
>>      pkidir_must_exist
>>
>> -    request_file="`pwd`/$1"
>> +    if [ "`echo $1 | cut -c1`" = "/" ]; then
>> +        request_file="$1"
>> +    else
>> +        request_file="`pwd`/$1"
>> +    fi
>> +
>>      (cd "$pkidir/${type}ca" &&
>>       openssl ca -config ca.cnf -batch -in "$request_file") \
>>          > "$2.tmp$$" 2>&3
>>
>> On Wed, May 14, 2014 at 12:58 PM, Ben Pfaff <b...@nicira.com> wrote:
>> > On May 14, 2014 11:35 AM, "Gurucharan Shetty" <shet...@nicira.com>
>> > wrote:
>> >>
>> >> On Wed, May 14, 2014 at 11:18 AM, Ben Pfaff <b...@nicira.com> wrote:
>> >> > On Tue, May 13, 2014 at 09:03:18AM -0700, Gurucharan Shetty wrote:
>> >> >> This lets us generate certs for unit tests on Windows
>> >> >>
>> >> >> Signed-off-by: Gurucharan Shetty <gshe...@nicira.com>
>> >> >
>> >> > This will fail if $1 is absolute (if it begins with /):
>> >> >> +    request_file="`pwd`/$1"
>> >> Reading the man page gave me an impression that 'name' is just a
>> >> prefix. I guess not. I will fix it in v2.
>> >
>> > I think that it would most commonly be just a simple prefix, but i can
>> > imagine a script calling ovs-pki with a fully qualified name as that
>> > prefix.
>> > Since (I guess) this worked before, I'd like it to continue working.
>> >
>> > Thanks,
>> >
>> > Ben.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to