On Sun, November 3, 2019 12:02 pm, trondd wrote:
> On Sun, November 3, 2019 6:27 am, Florian Obser wrote:
>> On Sun, Nov 03, 2019 at 12:21:59PM +0100, Antoine Jacoutot wrote:
>>> On Sun, Nov 03, 2019 at 12:16:56PM +0100, Florian Obser wrote:
>>> > I like it, if someone who is fluent in ksh line noise could please
>>> > verify and commit, that would be awesome, thanks.
>>>
>>> Why not let the installer handle this? It already has code for it.
>>> sysupgrade ony needs to create the proper auto_upgrade.conf containing
>>> the
>>> answer to the proxy question.
>>
>> Right, that is better.
>>
>
> Unless I'm missing something, the installer only asks for a proxy when you
> select 'http' for the sets for a network install which sysupgrade is
> designed to not do.
>
> This would mean changing the installer to ask for a proxy regardless of
> install method.  Which could make sense since the execution of tools in
> rc.firsttime requires internet access regardless of set installation
> method.
>
> I don't know that much of a change is desired, though.
>
> Tim.
>

I've tested the diff and it works as expected in my environment.  I don't
need a username and password for proxy access but it populates the
rc.firsttime file fine.

The quote() function is actually pretty simple.

quote() (
        # Since this is a subshell we won't pollute the calling namespace.
        for _a; do
                # alias string to Q, does escaping and quoting
                alias Q=$_a;
                # set variable back to value of alias
                _a=$(alias Q);
                # print variable, chopping off alias definition
                #   no newline, don't substitute the escape sequences
                #   we made above
                print -rn -- " ${_a#Q=}"
        done | sed '1s/ //'
        echo
)

$ export "test=fancy ' stuff #and not a comment"
$ ./quote.ksh
$ cat test.out

export 'http_proxy=fancy '\'' stuff #and not a comment'

$ export "test=even
> this works #"
$ ./quote.ksh
$ cat test.out

export 'http_proxy=even
this works #'


Tim.


>>>
>>>
>>> >
>>> > On Fri, Nov 01, 2019 at 09:37:04PM -0400, trondd wrote:
>>> > > Anthony Coulter <b...@anthonycoulter.name> wrote:
>>> > >
>>> > > > Hello @tech,
>>> > > >
>>> > > > When I manually upgrade OpenBSD using bsd.rd, I have to set
>>> http_proxy
>>> > > > to fetch the file sets. When I reboot after installing, fw_update
>>> > > > succeeds because theinstall script was clever enough to export
>>> > > > http_proxy in /etc/rc.firsttime.
>>> > > >
>>> > > > Unfortunately sysupgrade(8) does not remember that http_proxy was
>>> set
>>> > > > when it fetched the file sets, and so when I run sysupgrade I
>>> have
>>> to
>>> > > > either wait for fw_update to manually time out on first reboot,
>>> or
>>> kill
>>> > > > it manually with ^C.
>>> > > >
>>> > > > Adding the line:
>>> > > >
>>> > > > [ ${http_proxy} ] && echo "export http_proxy=${http_proxy}"
>>> >>/etc/rc.firsttime
>>> > > >
>>> > > > to a spot near the bottom of /usr/sbin/sysupgrade fixes my
>>> fw_update
>>> > > > problem, at least until the upgrade restores all of my files to
>>> their
>>> > > > stock defaults. Is this something we could integrate into the
>>> official
>>> > > > repository?
>>> > > >
>>> > > > Thanks and regards,
>>> > > > Anthony Coulter
>>> > >
>>> > > Here it is in patch form in case there is interest.  This also
>>> pulls
>>> in the
>>> > > quote function from install.sub to make sure a proxy username or
>>> password is
>>> > > quoted properly.  I haven't tested this since I could only use it
>>> at
>>> work.
>>> > >
>>> > > Tim.
>>> > >
>>> > >
>>> > > Index: sysupgrade.sh
>>> > > ===================================================================
>>> > > RCS file: /cvs/src/usr.sbin/sysupgrade/sysupgrade.sh,v
>>> > > retrieving revision 1.29
>>> > > diff -u -p -r1.29 sysupgrade.sh
>>> > > --- sysupgrade.sh       26 Oct 2019 04:04:20 -0000      1.29
>>> > > +++ sysupgrade.sh       2 Nov 2019 00:39:05 -0000
>>> > > @@ -73,6 +73,16 @@ rmel() {
>>> > >         echo -n "$_c"
>>> > >  }
>>> > >
>>> > > +# Prints the supplied parameters properly escaped for future
>>> sh/ksh
>>> parsing.
>>> > > +# Quotes are added if needed, so you should not do that yourself.
>>> > > +quote() (
>>> > > +       # Since this is a subshell we won't pollute the calling
>>> namespace.
>>> > > +       for _a; do
>>> > > +               alias Q=$_a; _a=$(alias Q); print -rn -- " ${_a#Q=}"
>>> > > +       done | sed '1s/ //'
>>> > > +       echo
>>> > > +)
>>> > > +
>>> > >  RELEASE=false
>>> > >  SNAP=false
>>> > >  FORCE=false
>>> > > @@ -199,6 +209,9 @@ if ! ${KEEP}; then
>>> > >  rm -f /home/_sysupgrade/{${CLEAN}}
>>> > >  __EOT
>>> > >  fi
>>> > > +
>>> > > +[[ -n $http_proxy ]] &&
>>> > > +       quote export "http_proxy=$http_proxy" >>/etc/rc.firsttime
>>> > >
>>> > >  install -F -m 700 bsd.rd /bsd.upgrade
>>> > >  sync
>>> > >
>>> >
>>> > --
>>> > I'm not entirely sure you are real.
>>> >
>>>
>>> --
>>> Antoine
>>>
>>
>> --
>> I'm not entirely sure you are real.
>>
>


Reply via email to