10

Why would a specific man page (in my case, for the nc command) have today's date without me doing any updates to the system ? Also, why doesn't the "unattended update" log show any specific activity for that day?

2018-03-14 07:47:38,124 INFO Initial blacklisted packages:
2018-03-14 07:47:38,135 INFO Starting unattended upgrades script
2018-03-14 07:47:38,135 INFO Allowed origins are: ['o=LinuxMint,a=qiana-security', 'o=LinuxMintESM,a=qiana']
2018-03-14 07:47:51,767 INFO No packages found that can be upgraded unattended and no pending auto-removals

This is footer for the nc man page:

BSD                             March 14, 2018                             BSD

That's on Linux Mint 17 (qiana), based on Ubuntu 14.04 (trusty) with groff 1.22.2 and man-db 2.6.7.1.

EDIT

Requested commands outputs :

  1. man -aw nc

    /usr/share/man/man1/nc_openbsd.1.gz
    
  2. ls -ld $(man -aw nc)

    -rw-r--r-- 1 root root 5.7K Dec  4  2012 /usr/share/man/man1/nc_openbsd.1.gz
    

Which is weird...

  1. dpkg -S $(man -aw nc)?

    netcat-openbsd: /usr/share/man/man1/nc_openbsd.1.gz
    
  2. type -a man

    man is /usr/bin/man
    
  3. zgrep docdate $(man -aw nc)

    .Dd $Mdocdate: February 7 2012 $
    
  4. ADDED FOOTER strace -f man nc 2>&1 | grep -e '^BSD' -e '"/.*nc'

    ychaouche#ychaouche-PC 14:31:15 ~ $ strace -f man nc 2>&1 | grep -e '^BSD' -e '"/.*nc'
    execve("/usr/bin/man", ["man", "nc"], [/* 87 vars */]) = 0
    lstat("/usr/share/man/man1/nc.1.gz", {st_mode=S_IFLNK|0777, st_size=25, ...}) = 0
    lstat("/usr/share/man/man1/nc.1.gz", {st_mode=S_IFLNK|0777, st_size=25, ...}) = 0
    readlink("/usr/share/man/man1/nc.1.gz", "/etc/alternatives/nc.1.gz", 4095) = 25
    lstat("/etc/alternatives/nc.1.gz", {st_mode=S_IFLNK|0777, st_size=35, ...}) = 0
    readlink("/etc/alternatives/nc.1.gz", "/usr/share/man/man1/nc_openbsd.1"..., 4095) = 35
    lstat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    stat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    stat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    open("/usr/share/man/man1/nc_openbsd.1.gz", O_RDONLY) = 3
    access("/usr/share/man/man1/nc.1.gz", R_OK) = 0
    lstat("/usr/share/man/man1/nc.1.gz", {st_mode=S_IFLNK|0777, st_size=25, ...}) = 0
    lstat("/usr/share/man/man1/nc.1.gz", {st_mode=S_IFLNK|0777, st_size=25, ...}) = 0
    readlink("/usr/share/man/man1/nc.1.gz", "/etc/alternatives/nc.1.gz", 4095) = 25
    lstat("/etc/alternatives/nc.1.gz", {st_mode=S_IFLNK|0777, st_size=35, ...}) = 0
    readlink("/etc/alternatives/nc.1.gz", "/usr/share/man/man1/nc_openbsd.1"..., 4095) = 35
    lstat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    stat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    stat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    open("/usr/share/man/man1/nc_openbsd.1.gz", O_RDONLY) = 3
    stat("/usr/share/man/man1/nc.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    stat("/usr/share/man/cat1/nc.1.gz", 0x7fffa49c0940) = -1 ENOENT (No such file or directory)
    stat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    open("/usr/share/man/man1/nc_openbsd.1.gz", O_RDONLY) = 3
    [pid  3878] stat("/usr/share/man/man1/nc_openbsd.1.gz", {st_mode=S_IFREG|0644, st_size=5756, ...}) = 0
    [pid  3878] access("/usr/share/man/man1/nc_openbsd.1.gz", R_OK <unfinished ...>
    BSD                             March 20, 2018                             BSD
    
  5. strace -f man nc 2>&1 | grep -vwe -1 | grep -o '"/[^"]*"' | sort -u | grep -v /dev/ | xargs sh -c 'zgrep "March 14" "$@"' sh 2> /dev/null

     no output
    

    it seems the date isn't hardcoded. Could be a macro generating today's date.

  6. env | grep -e ROFF -e MAN -e GRO

    SESSION_MANAGER=local/ychaouche-PC:@/tmp/.ICE-unix/2915,unix/ychaouche-PC:/tmp/.ICE-unix/2915
    MANDATORY_PATH=/usr/share/gconf/default.mandatory.path
    
  7. env -i man nc shows today's date (March 20th 2018)

  8. zcat /usr/share/man/man1/nc_openbsd.1.gz | nroff -mandoc | grep BSD

    ychaouche#ychaouche-PC 06:59:53 ~ $ zcat /usr/share/man/man1/nc_openbsd.1.gz | nroff -mandoc | grep BSD
    NC(1)                     BSD General Commands Manual                    NC(1)
    BSD                             March 20, 2018                             BSD
    ychaouche#ychaouche-PC 07:01:41 ~ $
    
  9. strace -f man nc 2>&1 | grep -vwe -1 | grep -o '"/[^"]*tmac/[^"]*"' | sort -u | xargs ls -lrtd

    ychaouche#ychaouche-PC 17:26:08 /usr/share/man/man1 $ unalias ls
    ychaouche#ychaouche-PC 17:26:12 /usr/share/man/man1 $ unalias xargs
    ychaouche#ychaouche-PC 17:26:14 /usr/share/man/man1 $ unalias grep
    ychaouche#ychaouche-PC 17:26:16 /usr/share/man/man1 $ strace -f man nc 2>&1 | grep -vwe -1 | grep -o '"/[^"]*tmac/[^"]*"' | sort -u | xargs ls -lrtd
    -rw-r--r-- 1 root root  4065 Jan 22  2014 /usr/share/groff/1.22.2/tmac/papersize.tmac
    -rw-r--r-- 1 root root  1860 Jan 22  2014 /usr/share/groff/1.22.2/tmac/andoc.tmac
    -rw-r--r-- 1 root root    71 Jan 22  2014 /usr/share/groff/1.22.2/tmac/unicode.tmac
    -rw-r--r-- 1 root root  1552 Jan 22  2014 /usr/share/groff/1.22.2/tmac/tty.tmac
    -rw-r--r-- 1 root root  5183 Jan 22  2014 /usr/share/groff/1.22.2/tmac/tty-char.tmac
    -rw-r--r-- 1 root root  1145 Jan 22  2014 /usr/share/groff/1.22.2/tmac/troffrc-end
    -rw-r--r-- 1 root root  1387 Jan 22  2014 /usr/share/groff/1.22.2/tmac/troffrc
    -rw-r--r-- 1 root root  4729 Jan 22  2014 /usr/share/groff/1.22.2/tmac/pspic.tmac
    -rw-r--r-- 1 root root 22042 Jan 22  2014 /usr/share/groff/1.22.2/tmac/mdoc/doc-syms
    -rw-r--r-- 1 root root  4048 Jan 22  2014 /usr/share/groff/1.22.2/tmac/mdoc/doc-nroff
    -rw-r--r-- 1 root root 29284 Jan 22  2014 /usr/share/groff/1.22.2/tmac/mdoc/doc-common
    -rw-r--r-- 1 root root  2250 Jan 22  2014 /usr/share/groff/1.22.2/tmac/latin1.tmac
    -rw-r--r-- 1 root root 27860 Jan 22  2014 /usr/share/groff/1.22.2/tmac/hyphen.us
    -rw-r--r-- 1 root root 15678 Jan 22  2014 /usr/share/groff/1.22.2/tmac/hyphenex.us
    -rw-r--r-- 1 root root  1362 Jan 22  2014 /usr/share/groff/1.22.2/tmac/fallbacks.tmac
    -rw-r--r-- 1 root root 73807 Jan 22  2014 /usr/share/groff/1.22.2/tmac/doc.tmac
    -rw-r--r-- 1 root root   537 Jan 22  2014 /usr/share/groff/1.22.2/tmac/composite.tmac
    -rw-r--r-- 1 root root   704 Jan 22  2014 /usr/share/groff/site-tmac/mdoc.local
    ychaouche#ychaouche-PC 17:26:18 /usr/share/man/man1 $
    
ychaouche
  • 945
  • 8
  • 25
  • It was today yesterday. I updated the post description to include the requested commands output. – ychaouche Mar 15 '18 at 12:59
  • The manpage’s source code is visible [here](https://sources.debian.org/src/netcat-openbsd/1.105-7/nc.1/) (in the version apparently installed on the OP’s system). – Stephen Kitt Mar 15 '18 at 17:41
  • Is ‘man’ aliased or overridden? `type -a man` output would help. – Jeff Schaller Mar 15 '18 at 23:20
  • `man is /usr/bin/man` – ychaouche Mar 18 '18 at 10:10
  • @Stéphane see https://sources.debian.org/src/netcat-openbsd/1.105-7/nc.1/#L28 – Stephen Kitt Mar 19 '18 at 09:28
  • surprisingly, I get `.Dd $Mdocdate: February 7 2012 $` – ychaouche Mar 19 '18 at 09:35
  • How about `strace -f man nc 2>&1 | grep -e '^BSD' -e '"/.*nc'` – Stéphane Chazelas Mar 19 '18 at 09:42
  • That's a lot of though on such a small problem :D – Kiwy Mar 19 '18 at 09:46
  • 2
    @Kiwy, well, that's an intriguing problem. And could be caused by a bigger problem. – Stéphane Chazelas Mar 19 '18 at 09:50
  • And maybe `strace -f man nc 2>&1 | grep -vwe -1 | grep -o '"/[^"]*"' | sort -u | grep -v /dev/ | xargs sh -c 'zgrep "March 14" "$@"' sh 2> /dev/null` to try and see where that `March 14` comes from. – Stéphane Chazelas Mar 19 '18 at 09:52
  • Do you get the same with `env -i man nc`? Do you have any roff or man-related variable in your environment? (`env | grep -e ROFF -e MAN -e GRO`)? – Stéphane Chazelas Mar 19 '18 at 09:55
  • @StéphaneChazelas true, I will try to decrypt what your asking for, those command could be usefull one day. – Kiwy Mar 19 '18 at 10:00
  • @StéphaneChazelas I edited the question with requested output – ychaouche Mar 19 '18 at 13:40
  • The `grep -e '^BSD'` doesn't show the footer line. Is it still showing `March 14`? Or today's `date` (`March 19`)? What about the `env -i`? Do you get the same footer if you call nroff directly (`zcat /usr/share/man/man1/nc_openbsd.1.gz | nroff -mandoc | grep BSD`)? – Stéphane Chazelas Mar 19 '18 at 13:49
  • Maybe `strace -f man nc 2>&1 | grep -vwe -1 | grep -o '"/[^"]*tmac/[^"]*"' | sort -u | xargs ls -lrtd` to see if there have been recent modifications to some roff macros – Stéphane Chazelas Mar 19 '18 at 13:54
  • @StéphaneChazelas, I forgot to mention that it is showiong today's date on each day now. The first time I encoutered this problem it showed the same date on two consecutive dates (today on first day and yesterday on second day), maybe because I didn't reboot the system on that particular day ? – ychaouche Mar 20 '18 at 06:08
  • That you had to remove the quotes is also odd. Does `echo '"/"' | xargs ls -ld` not work? `xargs` is meant to recognise quotes (that part I cannot reproduce on Ubuntu 14.04) – Stéphane Chazelas Mar 20 '18 at 12:33
  • Ah it must be that my xargs is aliased to `xargs -0 --delimiter='\n'` – ychaouche Mar 20 '18 at 16:25
  • 1
    `-0` and `--delimiter='\n'` make little sense together (one sets the delimiter to NUL, the other to LF) – Stéphane Chazelas Mar 20 '18 at 16:52

1 Answers1

10

GNU roff used not to support those:

 .Dd $Mdocdate: February 7 2012 $

OpenBSD extension (here that $Mdocdate: ...$ being a CVS/RCS keyword expanded by CVS (which OpenBSD uses to version control their code) with the date of the manual revision), resulting in the current date to be expanded instead of the one specified. I can reproduce it on Ubuntu 14.04 for all man pages that have such a Mdocdate.

See https://savannah.gnu.org/bugs/?42968 implemented in https://lists.gnu.org/archive/html/groff-commit/2014-10/msg00092.html (groff version 1.22.3).


For man pages from MirBSD (now MirOS) like your paxcpio or mksh, which use the same $Mdocdate: ...$ CVS keyword, you'll find the man pages redefine (wrap) the .Dd mdoc macro themselves, so the roff system macros don't have to support it:

.\"
.\" Implement .Dd with the Mdocdate RCS keyword
.\"
.rn Dd xD
.de Dd
.ie ^G\\$1^G$Mdocdate:^G \{\
.       xD \\$2 \\$3, \\$4
.\}
.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
..
.\"
.\" .Dd must come before definition of .Mx, because when called
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
.Dd $Mdocdate: August 16 2017 $
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
  • 1
    That was one brilliant debugging. Thanks a lot. – ychaouche Mar 20 '18 at 12:24
  • 1
    @ychaouche, now looking backward, that should have been one of the few things to look at, but for some reason I thought your Mint Qiana was based on Ubuntu 16.04 instead of 14.04 and couldn't reproduce it on 16.04 – Stéphane Chazelas Mar 20 '18 at 12:27
  • Using zgrep as shown in your comment, I made a list of all the man pages that had this "bug" : https://gist.github.com/ychaouche/fabe43225d1692dc325826d2be521bc4. I manually verified some of them, the bug is there. But it seems to have been fixed in Debian 8 (using 8.10 on one of the servers, bug not there.) – ychaouche Mar 20 '18 at 16:20
  • `man ssh` shows the current date on a Debian 8.10 system here with groff 1.22.2-8. Maybe you get the `groff` package from a newer release (stretch has 1.22.3). See `apt-cache policy groff`. – Stéphane Chazelas Mar 20 '18 at 16:51
  • No I was mislead by `man paxcpio` ! debian 8.10 here too, confirming bug for `man ssh` and `man ssh-keygen` as well, but `man paxcpio` shows `MirBSD June 5, 2012 MirBSD` – ychaouche Mar 21 '18 at 08:04
  • Manually checked and confirmed for the following man pages : https://gist.github.com/ychaouche/f4201c5f68cb7b15ee2fa41f3cbe841c – ychaouche Mar 21 '18 at 09:20
  • 1
    @ychaouche, it's not really a bug, it's that OpenBSD added a new format for the `.Dd` mdoc macro (which otherwise accepts `Month day, year`), so they could use CVS keyword in it (here `$Mdocdate: ... $` which is expanded by CVS to the date of the document revision). They updated their own `mdoc` macros for that and those modifcations were later merged into groff so that OpenBSD man pages could be properly formatted on other systems. – Stéphane Chazelas Mar 21 '18 at 09:28