diff asr_run.3
Hi, asr_run.3 is explaining that ar_rrsetinfo must be freed only for the blocking function, but I think it must be freed regardless of the function blocking type. ok? Index: lib/libc/asr/asr_run.3 === RCS file: /cvs/src/lib/libc/asr/asr_run.3,v retrieving revision 1.5 diff -u -p -r1.5 asr_run.3 --- lib/libc/asr/asr_run.3 31 Mar 2022 17:27:15 - 1.5 +++ lib/libc/asr/asr_run.3 20 Mar 2023 05:42:02 - @@ -259,7 +259,7 @@ Upon completion, the return code is foun .Fa ar_rrset_errno and the address to the newly allocated result set is set in .Fa ar_rrsetinfo . -As for the blocking function, it must be freed by calling +The caller must free it by calling .Xr freerrset 3 . .Pp The
Re: hack game: fix launch without /usr/games in path
On 31/05, Omar Polo wrote: Agreed. I prefer the second patch too, which I'm reattaching since it was mangled (whitespaces; 'patch -l' is not enough, but 'got patch' managed to apply it.) My bad, I am still not very comfortable with mailing patches, but I will learn. Will wait a bit still in case someone disagrees, but I don't really see the point in having hack scraping $PATH for finding itself; the format wasn't changed since the initial import so I guess we'll be fine :-) Thank you!
Re: smtpd: add missing time.h include
On Wed, 31 May 2023 11:00:37 +0200, Omar Polo wrote: > After a report of a build fail with some old gcc on RHEL7 / Centos, I > noticed that we're lacking the include time.h for time(3), > clock_gettime(3) and localtime(3). Diff below adds it in all the > missing files. I'm also including sys/time.h in smtpd.h, as noted in > event_init(3), since we're including event.h. OK millert@ - todd
Re: ix(4): LRO forwarding
On Thu, May 25, 2023 at 10:40:51PM +0200, Jan Klemkow wrote: > On Wed, May 24, 2023 at 05:28:58PM +0200, Alexander Bluhm wrote: > > On Tue, May 23, 2023 at 02:14:57PM +0200, Jan Klemkow wrote: > > > This diff sets needed offloading flags and the calculated mss to LRO > > > mbufs in ix(4). Thus, we can forward this packets and process them via > > > tcp_if_output_tso(). This diff also uses tcp_if_output_tso() in > > > ip6_forward(). After lot of testing by Hrvoje and fixing corner cases with Jan, this is the diff we currently have. There a no more known problems with TCP large receive offloading. ok? bluhm Index: dev/pci/if_ix.c === RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_ix.c,v retrieving revision 1.196 diff -u -p -r1.196 if_ix.c --- dev/pci/if_ix.c 23 May 2023 09:16:16 - 1.196 +++ dev/pci/if_ix.c 31 May 2023 13:48:25 - @@ -3245,6 +3245,8 @@ ixgbe_rxeof(struct rx_ring *rxr) sendmp = NULL; mp->m_next = nxbuf->buf; } else { /* Sending this frame? */ + uint16_t pkts; + ixgbe_rx_checksum(staterr, sendmp); if (hashtype != IXGBE_RXDADV_RSSTYPE_NONE) { @@ -3252,19 +3254,45 @@ ixgbe_rxeof(struct rx_ring *rxr) SET(sendmp->m_pkthdr.csum_flags, M_FLOWID); } - if (sendmp->m_pkthdr.ph_mss == 1) - sendmp->m_pkthdr.ph_mss = 0; + pkts = sendmp->m_pkthdr.ph_mss; + sendmp->m_pkthdr.ph_mss = 0; - if (sendmp->m_pkthdr.ph_mss > 0) { + if (pkts > 1) { struct ether_extracted ext; - uint16_t pkts = sendmp->m_pkthdr.ph_mss; + uint32_t hdrlen, paylen; + /* Calculate header size. */ ether_extract_headers(sendmp, &ext); - if (ext.tcp) + hdrlen = sizeof(*ext.eh); + if (ext.ip4) + hdrlen += ext.ip4->ip_hl << 2; + if (ext.ip6) + hdrlen += sizeof(*ext.ip6); + if (ext.tcp) { + hdrlen += ext.tcp->th_off << 2; tcpstat_inc(tcps_inhwlro); - else + tcpstat_add(tcps_inpktlro, pkts); + } else { tcpstat_inc(tcps_inbadlro); - tcpstat_add(tcps_inpktlro, pkts); + } + + /* +* If we gonna forward this packet, we have to +* mark it as TSO, set a correct mss, +* and recalculate the TCP checksum. +*/ + paylen = sendmp->m_pkthdr.len - hdrlen; + if (ext.tcp && paylen >= pkts) { + SET(sendmp->m_pkthdr.csum_flags, + M_TCP_TSO); + sendmp->m_pkthdr.ph_mss = paylen / pkts; + } + if (ext.tcp && + ISSET(sendmp->m_pkthdr.csum_flags, + M_TCP_CSUM_IN_OK)) { + SET(sendmp->m_pkthdr.csum_flags, + M_TCP_CSUM_OUT); + } } ml_enqueue(&ml, sendmp); Index: netinet6/ip6_forward.c === RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/ip6_forward.c,v retrieving revision 1.109 diff -u -p -r1.109 ip6_forward.c --- netinet6/ip6_forward.c 5 Apr 2023 13:56:31 - 1.109 +++ netinet6/ip6_forward.c 31 May 2023 13:48:25 - @@ -63,8 +63,10 @@ #include #include #include -#include #endif +#include +#include +#include /* * Forward a packet. If some error occurs return the sender @@ -316,7 +318,11 @@ reroute: goto reroute; } #endif - in6_proto_cksum_out(m, ifp); + + error = tcp_if_output_tso(ifp, &m, sin6tosa(sin6), rt, IFCAP_TSOv6, + ifp->if_mtu); + if (error || m == NULL) + goto freecopy; /* Check the size after pf_test to give pf a chance to refragment. */ if (m->m_pkthdr.len > ifp->if_mtu) { @@ -327,6 +333,7 @@
Re: ifconfig description for wireguard peers
On Wed, May 31, 2023 at 10:27:13AM +0200, Claudio Jeker wrote: > On Tue, May 30, 2023 at 11:56:01PM +, Klemens Nanni wrote: > > On Tue, May 23, 2023 at 07:13:28PM +, Klemens Nanni wrote: > > > On Sat, Jan 14, 2023 at 02:28:27PM +, Stuart Henderson wrote: > > > > On 2023/01/12 04:49, Mikolaj Kucharski wrote: > > > > > Hi, > > > > > > > > > > Is there anything else which I can do, to help this diff reviwed and > > > > > increase the chance of getting in? > > > > > > > > > > Thread at https://marc.info/?t=16347829861&r=1&w=2 > > > > > > > > > > Last version of the diff at > > > > > https://marc.info/?l=openbsd-tech&m=167185582521873&q=mbox > > > > > > > > Inlining that for a few comments, otherwise it's ok sthen > > > > > > wgdescr[iption] would be consistent with the existing descr[iption]. > > > At least my keep typing the trailing "r"... > > > > > > Then '-wgdescr' and 'wgdescr ""' work and are implemented exactly like > > > te inteface description equivalents. > > > > > > I could use this now in a new VPN setup, so here's a polished diff, > > > with the above, missing ifconfig.8 bits written and other nits inline. > > > > > > As Theo suggested, I'd drop the wg.4 and leave it to ifconfig.8 proper. > > > > > > Feedback? > > > > > > Either way, net/wireguard-tools needs a bump/rebuild. > > > > Updated diff at the end, grabbing the new per-description mutex also for > > reading, not just writing it. > > > > I did not run into an issue with the first two diffs, but other peer > > properties have their own mutex as well and they're consistently used > > for all accesses, as I'd expect, so protect new description properly. > > > > Also fixed ifconfig.8's wireguard synopsis bits. > > > > Anyone? > > This mutex makes very little sense to me. > Access to this field is already serialized by the sc->sc_lock rwlock > so there is no need for this mutex. Right, description is only read/written through the ioctl, whereas other stuff under its own mutex, e.g. peer rx/tx counters, need to serialise packet processing/actual counting with reading out from the ioctl layer. I did not look close enough, but lazily grabbed the original diff's mutex in all places. Hopefully the last diff. Index: sys/net/if_wg.c === RCS file: /cvs/src/sys/net/if_wg.c,v retrieving revision 1.27 diff -u -p -r1.27 if_wg.c --- sys/net/if_wg.c 30 May 2023 08:30:01 - 1.27 +++ sys/net/if_wg.c 31 May 2023 12:41:50 - @@ -221,6 +221,8 @@ struct wg_peer { SLIST_ENTRY(wg_peer) p_start_list; int p_start_onlist; + + char p_description[IFDESCRSIZE]; }; struct wg_softc { @@ -407,6 +409,8 @@ wg_peer_create(struct wg_softc *sc, uint peer->p_counters_tx = 0; peer->p_counters_rx = 0; + strlcpy(peer->p_description, "", IFDESCRSIZE); + mtx_init(&peer->p_endpoint_mtx, IPL_NET); bzero(&peer->p_endpoint, sizeof(peer->p_endpoint)); @@ -581,6 +585,11 @@ wg_peer_counters_add(struct wg_peer *pee mtx_leave(&peer->p_counters_mtx); } +void +wg_peer_get_description(struct wg_peer *peer, char *description) +{ +} + int wg_aip_add(struct wg_softc *sc, struct wg_peer *peer, struct wg_aip_io *d) { @@ -2320,6 +2329,10 @@ wg_ioctl_set(struct wg_softc *sc, struct } } + if (peer_o.p_flags & WG_PEER_SET_DESCRIPTION) + strlcpy(peer->p_description, peer_o.p_description, + IFDESCRSIZE); + aip_p = &peer_p->p_aips[0]; for (j = 0; j < peer_o.p_aips_count; j++) { if ((ret = copyin(aip_p, &aip_o, sizeof(aip_o))) != 0) @@ -2429,6 +2442,8 @@ wg_ioctl_get(struct wg_softc *sc, struct aip_count++; } peer_o.p_aips_count = aip_count; + + strlcpy(peer_o.p_description, peer->p_description, IFDESCRSIZE); if ((ret = copyout(&peer_o, peer_p, sizeof(peer_o))) != 0) goto unlock_and_ret_size; Index: sys/net/if_wg.h === RCS file: /cvs/src/sys/net/if_wg.h,v retrieving revision 1.4 diff -u -p -r1.4 if_wg.h --- sys/net/if_wg.h 22 Jun 2020 12:20:44 - 1.4 +++ sys/net/if_wg.h 29 May 2023 22:20:02 - @@ -61,6 +61,7 @@ struct wg_aip_io { #define WG_PEER_REPLACE_AIPS (1 << 4) #define WG_PEER_REMOVE (1 << 5) #define WG_PEER_UPDATE (1 << 6) +#define WG_PEER_SET_DESCRIPTION(1 << 7) #define p_sa p_endpoint.sa_sa #define p_sin p_endpoint.sa_sin @@ -80,6 +81,7 @@ struct wg_peer_io { uint64_tp_txbytes; uint64_tp_rxbytes; struct timespec p_last_handshake; /* nanotime */ + char
smtpd: add missing time.h include
Another boring diff from opensmtpd-portable. After a report of a build fail with some old gcc on RHEL7 / Centos, I noticed that we're lacking the include time.h for time(3), clock_gettime(3) and localtime(3). Diff below adds it in all the missing files. I'm also including sys/time.h in smtpd.h, as noted in event_init(3), since we're including event.h. It wouldn't be an issue to keep this in -portable, but since the header is genuinely missing I'd prefer to have it fixed in base too instead of relying on some other header to include it. diff /usr/src commit - 79631e141468cced94e502d777a484fa0eb1f60f path + /usr/src blob - 61e7b037bd90d2397e98e52cbb68e2436478b9b2 file + usr.sbin/smtpd/bounce.c --- usr.sbin/smtpd/bounce.c +++ usr.sbin/smtpd/bounce.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "smtpd.h" blob - 835ab5520eed8d8bbfcce21e9571f07ae89db97c file + usr.sbin/smtpd/control.c --- usr.sbin/smtpd/control.c +++ usr.sbin/smtpd/control.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "smtpd.h" blob - c90b60d2bb3ae7046621a4f576a900fe5557ebfd file + usr.sbin/smtpd/enqueue.c --- usr.sbin/smtpd/enqueue.c +++ usr.sbin/smtpd/enqueue.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "smtpd.h" blob - 894bf865a7662ce51138168aa0436fde6c9e7b44 file + usr.sbin/smtpd/mda.c --- usr.sbin/smtpd/mda.c +++ usr.sbin/smtpd/mda.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include blob - 05506da1dbef6fb33f23386727977c8e9118f2a8 file + usr.sbin/smtpd/mta.c --- usr.sbin/smtpd/mta.c +++ usr.sbin/smtpd/mta.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "smtpd.h" blob - 92f1ec7705d066698a7e24455b86774b86ccbb9c file + usr.sbin/smtpd/mta_session.c --- usr.sbin/smtpd/mta_session.c +++ usr.sbin/smtpd/mta_session.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include blob - e79e3f06be4fdf53e87596a6e10aa79fbe0ffde8 file + usr.sbin/smtpd/queue.c --- usr.sbin/smtpd/queue.c +++ usr.sbin/smtpd/queue.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "smtpd.h" blob - 646cd629879ba9c28d6ecaff8be2adef0cea0b7f file + usr.sbin/smtpd/queue_backend.c --- usr.sbin/smtpd/queue_backend.c +++ usr.sbin/smtpd/queue_backend.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "smtpd.h" blob - ec539eb9e1123fef50027467d430b94d688232b4 file + usr.sbin/smtpd/queue_fs.c --- usr.sbin/smtpd/queue_fs.c +++ usr.sbin/smtpd/queue_fs.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "smtpd.h" blob - 24ca71ca9ee765bcd6f1c05a24749ec6abce2ca8 file + usr.sbin/smtpd/runq.c --- usr.sbin/smtpd/runq.c +++ usr.sbin/smtpd/runq.c @@ -17,6 +17,7 @@ */ #include +#include #include "smtpd.h" blob - fa3b951bc77242dc73dd56d484e576b0ac6ffe8d file + usr.sbin/smtpd/scheduler_ramqueue.c --- usr.sbin/smtpd/scheduler_ramqueue.c +++ usr.sbin/smtpd/scheduler_ramqueue.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "smtpd.h" #include "log.h" blob - 72e13e8fd8d32d748cb64567953d52612a8140ff file + usr.sbin/smtpd/smtp_session.c --- usr.sbin/smtpd/smtp_session.c +++ usr.sbin/smtpd/smtp_session.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include blob - 84663025648861b28f691f99940938000c17872b file + usr.sbin/smtpd/smtpctl.c --- usr.sbin/smtpd/smtpctl.c +++ usr.sbin/smtpd/smtpctl.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include blob - 5949ce05522f4675aabc72042052ec0ef2025881 file + usr.sbin/smtpd/smtpd.c --- usr.sbin/smtpd/smtpd.c +++ usr.sbin/smtpd/smtpd.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include blob - 65757e517fdbe27cedea42656835d0ac7ef20c6b file + usr.sbin/smtpd/smtpd.h --- usr.sbin/smtpd/smtpd.h +++ usr.sbin/smtpd/smtpd.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include blob - 4a5c692e9508f763e6a2e83839afd6c9994821e6 file + usr.sbin/smtpd/to.c --- usr.sbin/smtpd/to.c +++ usr.sbin/smtpd/to.c @@ -23,6 +23,7 @@ #include #include #include +#include #if IO_TLS #include #endif
Re: ifconfig description for wireguard peers
On Tue, May 30, 2023 at 11:56:01PM +, Klemens Nanni wrote: > On Tue, May 23, 2023 at 07:13:28PM +, Klemens Nanni wrote: > > On Sat, Jan 14, 2023 at 02:28:27PM +, Stuart Henderson wrote: > > > On 2023/01/12 04:49, Mikolaj Kucharski wrote: > > > > Hi, > > > > > > > > Is there anything else which I can do, to help this diff reviwed and > > > > increase the chance of getting in? > > > > > > > > Thread at https://marc.info/?t=16347829861&r=1&w=2 > > > > > > > > Last version of the diff at > > > > https://marc.info/?l=openbsd-tech&m=167185582521873&q=mbox > > > > > > Inlining that for a few comments, otherwise it's ok sthen > > > > wgdescr[iption] would be consistent with the existing descr[iption]. > > At least my keep typing the trailing "r"... > > > > Then '-wgdescr' and 'wgdescr ""' work and are implemented exactly like > > te inteface description equivalents. > > > > I could use this now in a new VPN setup, so here's a polished diff, > > with the above, missing ifconfig.8 bits written and other nits inline. > > > > As Theo suggested, I'd drop the wg.4 and leave it to ifconfig.8 proper. > > > > Feedback? > > > > Either way, net/wireguard-tools needs a bump/rebuild. > > Updated diff at the end, grabbing the new per-description mutex also for > reading, not just writing it. > > I did not run into an issue with the first two diffs, but other peer > properties have their own mutex as well and they're consistently used > for all accesses, as I'd expect, so protect new description properly. > > Also fixed ifconfig.8's wireguard synopsis bits. > > Anyone? This mutex makes very little sense to me. Access to this field is already serialized by the sc->sc_lock rwlock so there is no need for this mutex. > Index: sys/net/if_wg.c > === > RCS file: /cvs/src/sys/net/if_wg.c,v > retrieving revision 1.27 > diff -u -p -r1.27 if_wg.c > --- sys/net/if_wg.c 30 May 2023 08:30:01 - 1.27 > +++ sys/net/if_wg.c 30 May 2023 15:37:41 - > @@ -221,6 +221,9 @@ struct wg_peer { > > SLIST_ENTRY(wg_peer) p_start_list; > int p_start_onlist; > + > + struct mutex p_description_mtx; > + char p_description[IFDESCRSIZE]; > }; > > struct wg_softc { > @@ -275,6 +278,8 @@ int wg_peer_get_sockaddr(struct wg_peer > void wg_peer_clear_src(struct wg_peer *); > void wg_peer_get_endpoint(struct wg_peer *, struct wg_endpoint *); > void wg_peer_counters_add(struct wg_peer *, uint64_t, uint64_t); > +void wg_peer_set_description(struct wg_peer *, const char *); > +void wg_peer_get_description(struct wg_peer *, char *); > > int wg_aip_add(struct wg_softc *, struct wg_peer *, struct wg_aip_io *); > struct wg_peer * > @@ -407,6 +412,9 @@ wg_peer_create(struct wg_softc *sc, uint > peer->p_counters_tx = 0; > peer->p_counters_rx = 0; > > + mtx_init(&peer->p_description_mtx, IPL_NET); > + strlcpy(peer->p_description, "", IFDESCRSIZE); > + > mtx_init(&peer->p_endpoint_mtx, IPL_NET); > bzero(&peer->p_endpoint, sizeof(peer->p_endpoint)); > > @@ -581,6 +589,22 @@ wg_peer_counters_add(struct wg_peer *pee > mtx_leave(&peer->p_counters_mtx); > } > > +void > +wg_peer_set_description(struct wg_peer *peer, const char *description) > +{ > + mtx_enter(&peer->p_description_mtx); > + strlcpy(peer->p_description, description, IFDESCRSIZE); > + mtx_leave(&peer->p_description_mtx); > +} > + > +void > +wg_peer_get_description(struct wg_peer *peer, char *description) > +{ > + mtx_enter(&peer->p_description_mtx); > + strlcpy(description, peer->p_description, IFDESCRSIZE); > + mtx_leave(&peer->p_description_mtx); > +} > + > int > wg_aip_add(struct wg_softc *sc, struct wg_peer *peer, struct wg_aip_io *d) > { > @@ -2320,6 +2344,9 @@ wg_ioctl_set(struct wg_softc *sc, struct > } > } > > + if (peer_o.p_flags & WG_PEER_SET_DESCRIPTION) > + wg_peer_set_description(peer, peer_o.p_description); > + > aip_p = &peer_p->p_aips[0]; > for (j = 0; j < peer_o.p_aips_count; j++) { > if ((ret = copyin(aip_p, &aip_o, sizeof(aip_o))) != 0) > @@ -2429,6 +2456,8 @@ wg_ioctl_get(struct wg_softc *sc, struct > aip_count++; > } > peer_o.p_aips_count = aip_count; > + > + wg_peer_get_description(peer, peer_o.p_description); > > if ((ret = copyout(&peer_o, peer_p, sizeof(peer_o))) != 0) > goto unlock_and_ret_size; -- :wq Claudio
Re: hack game: fix launch without /usr/games in path
On 2023/05/29 08:46:02 +0300, Anton Konyahin wrote: > I can suggest another (much less) patch, which still allows users to > play hack without path modification. But all this stuff with checking > saves creating time doesn't looks actual for me, so I keep original > patch below. Agreed. I prefer the second patch too, which I'm reattaching since it was mangled (whitespaces; 'patch -l' is not enough, but 'got patch' managed to apply it.) Will wait a bit still in case someone disagrees, but I don't really see the point in having hack scraping $PATH for finding itself; the format wasn't changed since the initial import so I guess we'll be fine :-) diff /usr/src commit - 79631e141468cced94e502d777a484fa0eb1f60f path + /usr/src blob - 4abe525065dddaabea09e3a050b3a3db78a10e39 file + games/hack/hack.bones.c --- games/hack/hack.bones.c +++ games/hack/hack.bones.c @@ -139,17 +139,15 @@ getbones(void) int getbones(void) { - int fd,x,y,ok; + int fd,x,y; if(rn2(3)) return(0); /* only once in three times do we find bones */ bones[6] = '0' + dlevel/10; bones[7] = '0' + dlevel%10; if((fd = open(bones, O_RDONLY)) == -1) return(0); - if((ok = uptodate(fd)) != 0){ - getlev(fd, 0, dlevel); - for(x = 0; x < COLNO; x++) for(y = 0; y < ROWNO; y++) - levl[x][y].seen = levl[x][y].new = 0; - } + getlev(fd, 0, dlevel); + for(x = 0; x < COLNO; x++) for(y = 0; y < ROWNO; y++) + levl[x][y].seen = levl[x][y].new = 0; (void) close(fd); #ifdef WIZARD if(!wizard) /* duvel!frans: don't remove bones while debugging */ @@ -158,5 +156,5 @@ getbones(void) pline("Cannot unlink %s .", bones); return(0); } - return(ok); + return(1); } blob - 4fa5eafc297d74a98cd106aadcc3ab67c5783b61 file + games/hack/hack.h --- games/hack/hack.h +++ games/hack/hack.h @@ -681,7 +681,6 @@ int uptodate(int); int night(void); int midnight(void); void gethdate(char *); -int uptodate(int); void getlock(void); #ifdef MAIL void getmailstatus(void); blob - 51a066600dbd8313b8fca95f7ef761e08c03e71d file + games/hack/hack.main.c --- games/hack/hack.main.c +++ games/hack/hack.main.c @@ -103,7 +103,6 @@ main(int argc, char **argv) int main(int argc, char **argv) { - extern char *__progname; int fd; #ifdef CHDIR char *dir; @@ -183,15 +182,6 @@ main(int argc, char **argv) u.ux = FAR; /* prevent nscr() */ (void) signal(SIGHUP, hackhangup); - /* -* Find the creation date of this game, -* so as to avoid restoring outdated savefiles. -*/ - gethdate(__progname); - - /* -* We cannot do chdir earlier, otherwise gethdate will fail. -*/ #ifdef CHDIR chdirx(dir,1); #endif @@ -298,8 +288,7 @@ main(int argc, char **argv) setftty(); (void) snprintf(SAVEF, sizeof SAVEF, "save/%u%s", getuid(), plname); regularize(SAVEF+5);/* avoid . or / in name */ - if((fd = open(SAVEF, O_RDONLY)) >= 0 && - (uptodate(fd) || unlink(SAVEF) == 666)) { + if((fd = open(SAVEF, O_RDONLY)) >= 0) { (void) signal(SIGINT,done1); pline("Restoring old save file..."); (void) fflush(stdout); blob - 96a9ca84d2f783477114095339b566d36cb4d17c file + games/hack/hack.unix.c --- games/hack/hack.unix.c +++ games/hack/hack.unix.c @@ -154,53 +154,8 @@ struct stat buf, hbuf; return(getlt()->tm_hour == 0); } -struct stat buf, hbuf; +struct stat buf; -void -gethdate(char *name) -{ - char *p, *np, *path; - char filename[PATH_MAX]; - - if (strchr(name, '/') != NULL || (p = getenv("PATH")) == NULL) - p = ""; - np = path = strdup(p); /* Make a copy for strsep. */ - if (path == NULL) - err(1, NULL); - - for (;;) { - if ((p = strsep(&np, ":")) == NULL) - break; - if (*p == '\0') /* :: */ - (void) strlcpy(filename, name, sizeof filename); - else - (void) snprintf(filename, sizeof filename, - "%s/%s", p, name); - - if (stat(filename, &hbuf) == 0) { - free(path); - return; - } - } - error("Cannot get status of %s.", - (p = strrchr(name, '/')) ? p+1 : name); - free(path); -} - -int -uptodate(int fd) -{ - if(fstat(fd, &buf)) { - pline("Cannot get status of saved level? "); - return(0); - } - if(buf.st_mtime < hbuf.st_mtime) { - pline("Saved level is out of date. "); - return(0); - } - return(1); -} - /* see whether we should throw away this xlock file */ static int veryold(int fd)