Bug 201405 - www/squid : why is /var/run/squid not installed? (causing issue)
Summary: www/squid : why is /var/run/squid not installed? (causing issue)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-07 16:12 UTC by John Marino
Modified: 2015-09-21 11:08 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (timp87)


Attachments
Half of DF fix (326 bytes, patch)
2015-07-07 17:55 UTC, John Marino
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Marino freebsd_committer freebsd_triage 2015-07-07 16:12:59 UTC
In the post-install target, the /var/run/squid directory is intentionally removed (as opposed to adding @dir /var/run/squid in pkg-plist)

What is the reason for this?

I believe the following code is affected by this:

 /src/ipc/mem/Segment.cc 

/// Generate name for shared memory segment. Starts with a prefix required
/// for cross-platform portability and replaces all slashes in ID with dots.
String
Ipc::Mem::Segment::GenerateName(const char *id)
{
    assert(BasePath && *BasePath);
    static const bool nameIsPath = shm_portable_segment_name_is_path();
    String name;
    if (nameIsPath) {
        name.append(BasePath);
        if (name[name.size()-1] != '/')
            name.append('/');
    } else
        name.append("/squid-");

    // append id, replacing slashes with dots
    for (const char *slash = strchr(id, '/'); slash; slash = strchr(id, '/')) {
        if (id != slash) {
            name.append(id, slash - id);
            name.append('.');
        }
        id = slash + 1;
    }
    name.append(id);

    name.append(".shm"); // to distinguish from non-segments when nameIsPath
    return name;
}


I got this report:
After installing Squid via Dports and "squid -z" i get the following error:
FATAL: Ipc::Mem::Segment::create failed to shm_open(/squid-cf__metadata.shm): (13) Permission denied
What goes wrong?

It should be trying to create it at /var/run/squid/squid-cf__metadata.shm.
However, because the directory does not exist, the code above tries /squid-cf__metadata.shm instead.

From what I see, the port should be pre-creating this directory.  Can you remind why it's intentionally being prevented from doing so?
Comment 1 John Marino freebsd_committer freebsd_triage 2015-07-07 16:16:01 UTC
note: BasePath is equal to "/var/run/squid" based on configure arguments.
Comment 2 John Marino freebsd_committer freebsd_triage 2015-07-07 17:12:29 UTC
It seems that shm_portable_segment_name_is_path is always false on DragonFly.

see compat/shm.cc
Comment 3 John Marino freebsd_committer freebsd_triage 2015-07-07 17:55:41 UTC
Created attachment 158512 [details]
Half of DF fix

Okay, we need to put this patch in /files.  DragonFly treats SHM segments as files.

But that means we need /var/run/squid pre-created as well.

So my original question is still valid -- why was the directory removed?  because it's empty with FreeBSD 7+ (all supported versions of FreeBSD) ?
Comment 4 Pavel Timofeev 2015-07-08 09:04:05 UTC
(In reply to John Marino from comment #0)
Hi, John!
That was committed back in days, I wasn't a committer of squid port then.

Here are commits:
https://svnweb.freebsd.org/ports?view=revision&revision=374991
and
https://svnweb.freebsd.org/ports?view=revision&revision=375163

I don't know the reason.


You can revert them and apply patch for DragonFlyBSD if you want.
Comment 5 John Marino freebsd_committer freebsd_triage 2015-07-08 09:07:39 UTC
okay, the changes will look something like this:

http://gitweb.dragonflybsd.org/dports.git/commitdiff/c0859319462b36c81e7e42eee26031f3ac232673
Comment 6 Pavel Timofeev 2015-07-08 09:17:39 UTC
(In reply to John Marino from comment #5)
ok. Will you commit it partially to freebsd ports?
Comment 7 commit-hook freebsd_committer freebsd_triage 2015-07-08 09:31:00 UTC
A commit references this bug:

Author: marino
Date: Wed Jul  8 09:30:19 UTC 2015
New revision: 391555
URL: https://svnweb.freebsd.org/changeset/ports/391555

Log:
  www/squid: Support DragonFly SHM segments

  Out of the box, squid would not run on dragonfly due to its handling
  of SHM segments.  On DragonFly, SHM segments are always treated as files
  but on FreeBSD it depends on whether or not application is inside a jail.

  In any case, the case for DragonFly was no supported, so it has been
  added via patch.  This also requires the return of /var/run/squid
  directory which is where the SHM files are stored (defined by
  localstatedir and supported by RC script).  The RC script would define
  this directory if missing, but let's make sure it is always available.

  PR:		201405
  Submitted by:	marino
  Approved by:	maintainer (timp87/gmail)

Changes:
  head/www/squid/Makefile
  head/www/squid/files/patch-compat_shm.cc
  head/www/squid/pkg-plist
Comment 8 John Marino freebsd_committer freebsd_triage 2015-07-08 09:33:13 UTC
Yes, done.

I think it was removed because the RC script will create the directory as needed.  In DragonFly's case, we need its available guaranteed (e.g. protect for case that squid is run directly without using RC script)

I also set ownership of /var/run/squid to squid:squid with mode 750.
Comment 9 commit-hook freebsd_committer freebsd_triage 2015-09-21 11:08:34 UTC
A commit references this bug:

Author: junovitch
Date: Mon Sep 21 11:08:26 UTC 2015
New revision: 397486
URL: https://svnweb.freebsd.org/changeset/ports/397486

Log:
  MFH r391555, r392222, r393602, r396106, r396185, r397215, r397476

  r391555
  www/squid: Support DragonFly SHM segments

  Out of the box, squid would not run on dragonfly due to its handling
  of SHM segments.  On DragonFly, SHM segments are always treated as files
  but on FreeBSD it depends on whether or not application is inside a jail.

  In any case, the case for DragonFly was no supported, so it has been
  added via patch.  This also requires the return of /var/run/squid
  directory which is where the SHM files are stored (defined by
  localstatedir and supported by RC script).  The RC script would define
  this directory if missing, but let's make sure it is always available.

  PR:		201405
  Submitted by:	marino
  Approved by:	maintainer (timp87/gmail)

  r392222
  www/squid: pkg-list fix

  - add missing pkg-plist entry (SSL_CRTD option)

  PR:                  201463
  Submitted by:        s3erios@gmail.com
  Approved by:         timp87@gmail.com (maintainer)

  r393602
  www/squid: update 3.5.6 -> 3.5.7

  - Fix build with ecap by clang
  - Get rid of useless and always empty /var/squid/logs
  - Rework patches to make portlint a bit happier

  PR:		202053
  Submitted by:	Pavel Timofeev <timp87@gmail.com> (maintainer)

  r396106
  www/squid: update 3.5.7 -> 3.5.8

  PR:		202826
  Submitted by:	Pavel Timofeev <timp87@gmail.com> (maintainer)
  Approved by:	feld (mentor)

  r396185
  Fix TP_IPF build.

  r397215
  Rather than produce a warning message that IPv6 is not supported
  under ipfilter 4 (FreeBSD 9) every tenth time, reduce the message
  to one in a million. This has the effect of displaying the message
  at or shortly after startup with a reminder every blue moon.

  PR:		202950

  r397476
  www/squid: security update and build fix

  - security update 3.5.8 -> 3.5.9 [1]
  - Fix TP_IPF build on FreeBSD 9 [2]

  PR:		203186 [1]
  PR:		202950 [2]
  Approved by:	Pavel Timofeev <timp87@gmail.com> (maintainer) [1]
  Security:	d3a98c2d-5da1-11e5-9909-002590263bf5
  Approved by:	portmgr (erwin)

Changes:
_U  branches/2015Q3/
  branches/2015Q3/www/squid/Makefile
  branches/2015Q3/www/squid/distinfo
  branches/2015Q3/www/squid/files/extra-patch-build-8-9
  branches/2015Q3/www/squid/files/patch-bug4190
  branches/2015Q3/www/squid/files/patch-compat_compat.h
  branches/2015Q3/www/squid/files/patch-compat_shm.cc
  branches/2015Q3/www/squid/files/patch-configure
  branches/2015Q3/www/squid/files/patch-configure_GSSAPI_NONE
  branches/2015Q3/www/squid/files/patch-configure_NIS
  branches/2015Q3/www/squid/files/patch-configure_crypt.h
  branches/2015Q3/www/squid/files/patch-src-cf.data.pre
  branches/2015Q3/www/squid/files/patch-src_DiskIO_Mmapped_MmappedFile.cc
  branches/2015Q3/www/squid/files/patch-src__ip__Intercept.cc
  branches/2015Q3/www/squid/files/patch-src_ipc_mem_Segment.cc
  branches/2015Q3/www/squid/files/patch-src_tools.cc
  branches/2015Q3/www/squid/pkg-plist