Undeadly interview

2020-01-19 Thread Mihai Popescu
Just in case someone else (like me) missed it:

http://undeadly.org/cgi?action=article;sid=20191231214356


Re: running git server with "smart http" protocol

2020-01-19 Thread Kent Watsen


For posterity, the issue was that the `git` command itself needs to be in the 
jail also.  This is not written down anywhere.  I only determined it after 
reading the source code for `git-http-backend`.

This is my init script now:

# cd /var/www
# for c in git git-http-backend git-upload-pack git-receive-pack ; do
for f in `ldd /usr/local/libexec/git/$c  | grep '/usr/' | grep 
-v ':' | awk '{print $7}'`; do
d=`dirname $f | sed 's#^/##'`
mkdir -p $d
cp $f $d
done
done

Also, regarding the rewrite rules mentioned before, they are only needed if 
wanting to discriminate between `git` and web requests pointing to the same URL.

Kent




Re: less --no-init and multiline $PS1

2020-01-19 Thread Ingo Schwarze
Hi,

Richard Ulmer wrote on Sun, Jan 19, 2020 at 12:44:37PM +0100:

> when using a $PS1, which has more than one line,

I consider multi-line $PS1 bloat that should not be supported,
in particular not when it complicates basic userland programs or
requires additions to their user interfaces.

On those grounds, i suggest to dismiss the patch.

Yours,
  Ingo



less --no-init and multiline $PS1

2020-01-19 Thread Richard Ulmer
Hi,
when using a $PS1, which has more than one line, `less --no-init` cuts
of some lines at the top, when it quits. This is especially annyoing
when using `git diff` and `git show`. For example,
`echo "foo\nbar" | less --no-init --quit-if-one-screen` with a two-line
$PS1 leads to terminal content like this:

.---.
| bar   |
| ~ |
| ~ |
| PS1 line 1|
| PS1 line 2$   |
`---'

I think, that using an environment variable like $PS1_LINES to inform
less about a multiline $PS1, would be a solution for the problem. This
is what I came up with:

Index: usr.bin/less/funcs.h
===
RCS file: /cvs/src/usr.bin/less/funcs.h,v
retrieving revision 1.25
diff -u -p -u -r1.25 funcs.h
--- usr.bin/less/funcs.h2 Sep 2019 14:07:45 -   1.25
+++ usr.bin/less/funcs.h19 Jan 2020 11:23:56 -
@@ -30,6 +30,7 @@ void ring_bell(void);
 void do_clear(void);
 void clear_eol(void);
 void clear_bot(void);
+void clear_above_bot(int);
 void at_enter(int);
 void at_exit(void);
 void at_switch(int);
Index: usr.bin/less/main.c
===
RCS file: /cvs/src/usr.bin/less/main.c,v
retrieving revision 1.37
diff -u -p -u -r1.37 main.c
--- usr.bin/less/main.c 28 Jun 2019 05:44:09 -  1.37
+++ usr.bin/less/main.c 19 Jan 2020 11:23:56 -
@@ -47,6 +47,7 @@ extern char   *tags;
 extern char*tagoption;
 extern int jump_sline;
 extern int less_is_more;
+extern int ps1_lines;
 extern int missing_cap;
 extern int know_dumb;
 extern int quit_if_one_screen;
@@ -102,6 +103,9 @@ main(int argc, char *argv[])
}
}
 
+   if ((s = lgetenv("PS1_LINES")) != NULL)
+   ps1_lines = atoi(s);
+
/*
 * Process command line arguments and LESS environment arguments.
 * Command line arguments override environment arguments.
@@ -383,8 +387,10 @@ quit(int status)
edit(NULL);
if (!secure)
save_cmdhist();
-   if (any_display && is_tty)
+   if (any_display && is_tty) {
clear_bot();
+   clear_above_bot(ps1_lines - 1);
+   }
deinit();
flush(1);
raw_mode(0);
Index: usr.bin/less/opttbl.c
===
RCS file: /cvs/src/usr.bin/less/opttbl.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 opttbl.c
--- usr.bin/less/opttbl.c   17 Sep 2016 15:06:41 -  1.19
+++ usr.bin/less/opttbl.c   19 Jan 2020 11:23:56 -
@@ -53,6 +53,7 @@ int opt_use_backslash;/* Use backslash 
 int hilite_search; /* Highlight matched search patterns? */
 
 int less_is_more = 0;  /* Make compatible with POSIX more */
+int ps1_lines = 1; /* Height of the primary prompt */
 
 /*
  * Long option names.
Index: usr.bin/less/screen.c
===
RCS file: /cvs/src/usr.bin/less/screen.c,v
retrieving revision 1.25
diff -u -p -u -r1.25 screen.c
--- usr.bin/less/screen.c   3 Sep 2019 23:08:42 -   1.25
+++ usr.bin/less/screen.c   19 Jan 2020 11:23:56 -
@@ -34,6 +34,7 @@ static char
*sc_lower_left, /* Cursor to last line, first column */
*sc_return, /* Cursor to beginning of current line */
*sc_move,   /* General cursor positioning */
+   *sc_up, /* Cursor up one line */
*sc_clear,  /* Clear screen */
*sc_eol_clear,  /* Clear to end of line */
*sc_eos_clear,  /* Clear to end of screen */
@@ -87,6 +88,7 @@ extern int tty;
 extern int top_scroll;
 extern int oldbot;
 extern int hilite_search;
+extern int ps1_lines;
 
 /*
  * Change terminal to "raw mode", or restore to "normal" mode.
@@ -414,6 +416,10 @@ get_term(void)
}
sc_lower_left = cheaper(t1, t2, "\r");
 
+   sc_up = cursor_up;
+   if (ps1_lines > 1 && sc_up == NULL)
+   missing_cap = 1;
+
/*
 * Get carriage return string.
 */
@@ -699,6 +705,20 @@ clear_bot(void)
at_exit();
clear_eol_bot();
at_enter(saved_attrmode);
+   }
+}
+
+/*
+ * Clear n lines above the bottom line of the display.
+ * The cursor must be set to the beginning of the bottom line before.
+ */
+void
+clear_above_bot(int n)
+{
+   int i;
+   for (i = 0; i < n; i++) {
+   tputs(sc_up, 1, putchr);
+   tputs(sc_eol_clear, 1, putchr);
}
 }
 



Re: Can't locate OpenBSD/Quirks.pm in @INC

2020-01-19 Thread Antoine Jacoutot
On Sun, Jan 19, 2020 at 12:19:31PM +0100, Marc Espie wrote:
> On Sat, Jan 18, 2020 at 01:41:20PM +0100, Antoine Jacoutot wrote:
> > On Fri, Jan 17, 2020 at 07:46:23PM -0700, myml...@gmx.com wrote:
> > > 
> > > On 1/17/20 7:25 PM, Jordan Geoghegan wrote:
> > > > 
> > > > 
> > > > On 2020-01-17 18:10, myml...@gmx.com wrote:
> > > > > HI,
> > > > > 
> > > > > 
> > > > > I downloaded the install66.fs snapshot today, 20200117, and did a 
> > > > > fresh
> > > > > install.  Even though I got the full install set, i used http from
> > > > > ftp.openbsd.org as the install source.
> > > > > 
> > > > > Installation went fine but when I tried to install packages I get the
> > > > > above error.
> > > > > 
> > > > > "# pkg_add -vn pftop
> > > > > quirks-3.216 signed on 2020-01-17T19:15:00Z
> > > > > quirks-3.216: ok
> > > > > Can't load quirk: Can't locate OpenBSD/Quirks.pm in @INC (you may need
> > > > > to install the OpenBSD::Quirks module) (@INC contains:
> > > > > /usr/local/libdata/perl5/site_perl/amd64-openbsd
> > > > > /usr/local/libdata/perl5/site_perl /usr/libdata/perl5/amd64-openbsd
> > > > > /usr/libdata/perl5) at /usr/libdata/perl5/OpenBSD/AddDelete.pm line 
> > > > > 350.
> > > > > 
> > > > > pftop-0.7p19: ok
> > > > > Merging manpages in /usr/local/man: /usr/local/man/man8/pftop.8
> > > > > Extracted 252817 from 253475"
> > > > > 
> > > > [snip]
> > > > 
> > > > I believe quirks gets automatically installed when you install your
> > > > first package.
> > > 
> > > 
> > > AH HA, that seems to be the case.
> > > 
> > >  pkg_add -v pftop
> > > quirks-3.216 signed on 2020-01-17T19:15:00Z
> > > quirks-3.216: ok
> > > pftop-0.7p19: ok
> > > Extracted 252817 from 253475
> > > 
> > > 
> > > I was just initially trying to see what would be installed without
> > > actually installing.  I've run into issues before where the base system
> > > packages and the userland stuff, if they aren't labeled the same date
> > > have library issues.  I was trying to make sure i'd avoid that.
> > > 
> > > 
> > > Thanks for the quick answer!
> >  
> > That is still a pkg_add bug though...
> 
> Thinking some more about it, I'm not sure about the right solution.
> - I can easily suppress the quirks warning if -n is given.

The problem is that you may get a different output compared to if quirks was
instaled (e.g. cve).

> - but then, quirks is kind-of part of pkg_add proper, so maybe it would be
> more appropriate to install quirks anyway.   This is a bit unexpected, though.

It would be unexpected yes.
Maybe quirks has become too quirky and we need a better solution?

-- 
Antoine



Re: Can't locate OpenBSD/Quirks.pm in @INC

2020-01-19 Thread Marc Espie
On Sat, Jan 18, 2020 at 01:41:20PM +0100, Antoine Jacoutot wrote:
> On Fri, Jan 17, 2020 at 07:46:23PM -0700, myml...@gmx.com wrote:
> > 
> > On 1/17/20 7:25 PM, Jordan Geoghegan wrote:
> > > 
> > > 
> > > On 2020-01-17 18:10, myml...@gmx.com wrote:
> > > > HI,
> > > > 
> > > > 
> > > > I downloaded the install66.fs snapshot today, 20200117, and did a fresh
> > > > install.  Even though I got the full install set, i used http from
> > > > ftp.openbsd.org as the install source.
> > > > 
> > > > Installation went fine but when I tried to install packages I get the
> > > > above error.
> > > > 
> > > > "# pkg_add -vn pftop
> > > > quirks-3.216 signed on 2020-01-17T19:15:00Z
> > > > quirks-3.216: ok
> > > > Can't load quirk: Can't locate OpenBSD/Quirks.pm in @INC (you may need
> > > > to install the OpenBSD::Quirks module) (@INC contains:
> > > > /usr/local/libdata/perl5/site_perl/amd64-openbsd
> > > > /usr/local/libdata/perl5/site_perl /usr/libdata/perl5/amd64-openbsd
> > > > /usr/libdata/perl5) at /usr/libdata/perl5/OpenBSD/AddDelete.pm line 350.
> > > > 
> > > > pftop-0.7p19: ok
> > > > Merging manpages in /usr/local/man: /usr/local/man/man8/pftop.8
> > > > Extracted 252817 from 253475"
> > > > 
> > > [snip]
> > > 
> > > I believe quirks gets automatically installed when you install your
> > > first package.
> > 
> > 
> > AH HA, that seems to be the case.
> > 
> >  pkg_add -v pftop
> > quirks-3.216 signed on 2020-01-17T19:15:00Z
> > quirks-3.216: ok
> > pftop-0.7p19: ok
> > Extracted 252817 from 253475
> > 
> > 
> > I was just initially trying to see what would be installed without
> > actually installing.  I've run into issues before where the base system
> > packages and the userland stuff, if they aren't labeled the same date
> > have library issues.  I was trying to make sure i'd avoid that.
> > 
> > 
> > Thanks for the quick answer!
>  
> That is still a pkg_add bug though...

Thinking some more about it, I'm not sure about the right solution.
- I can easily suppress the quirks warning if -n is given.

- but then, quirks is kind-of part of pkg_add proper, so maybe it would be
more appropriate to install quirks anyway.   This is a bit unexpected, though.



Re: How to set up default permission and group

2020-01-19 Thread Stuart Henderson
On 2020-01-18, Mik J  wrote:
> Hello,
> I want one for one of my user this behavior.Each time he creates a file it 
> needs to have permission/owner of rw-rw myuser www
> This user is executing a php script that creates a file and I want that file 
> to be read/write access by the user wwwI don't want to touch to the php 
> script.
> What is the good way to do that ?
> Regarding the group ? Should I make www the main group of myuser ?
> Thank you
>

The directory where the files are created must be owned by group www, then
you can set umask 007 before running the script.