Problems with permissions with squid3

26,439

squid3 runs as the user proxy, so you set the owner user (and group) as proxy and then set permissions accordingly.

You can do the following to change recursively the owner and owner group of all files under /var/cache/squid3 to user proxy and group proxy respectively:

sudo chown -R proxy:proxy /var/cache/squid3 

Also make sure the owner has the right permission, the permission you currently have i.e. 0755 will do.

In your case, as you can see the directory /var/cache/squid3 is only writable by root, hence you were getting the permission denied error.

Share:
26,439

Related videos on Youtube

John K
Author by

John K

...

Updated on September 18, 2022

Comments

  • John K
    John K almost 2 years

    I have been trying to get squid to work. I have a configuration for the cache to be created in the directory /var/cache/squid3/. However, I get this error when running squid with the "-z" tag (It is the first run):

    WARNING: Cannot write log file: /var/log/squid3/cache.log
    /var/log/squid3/cache.log: Permission denied
     messages will be sent to 'stderr'.
    2015/05/23 20:05:39 kid1| Creating missing swap directories
    2015/05/23 20:05:39 kid1| /var/cache/squid3 exists
    FATAL: Failed to make swap directory /var/cache/squid3/00: (13)
    Permission denied
    Squid Cache (Version 3.3.8): Terminated abnormally.
    CPU Usage: 0.010 seconds = 0.007 user + 0.003 sys
    Maximum Resident Size: 22560 KB
    Page faults with physical i/o: 0
    

    I tried to fix this with typing sudo chmod 755 /var/cache/squid3, however also without any success.

    The output of namei -l /var/cache/squid3 is:

    $ namei -l /var/cache/squid3
    f: /var/cache/squid3
    drwxr-xr-x root root /
    drwxr-xr-x root root var
    drwxr-xr-x root root cache
    drwxr-xr-x root root squid3
    

    UPDATE: I made new directories in /squid3_log and /squid3_cache. I then issued for both:

    sudo chown -R root:proxy /squid3_log #and squid3_cache
    

    and

    sudo chmod -R 777 /squid3_log #and squid3_cache
    

    It fixed the permission denied with squid3_cache but not with squid3_log.

    UPDATE: I tried purging, reinstalling, reconfiguring and it worked with first run squid3 -z. But then when I ran the debug squid3 -NCd1, It showed:

    2015/06/01 16:24:24| Starting Squid Cache version 3.3.8 for x86_64-pc-linux-gnu...
    2015/06/01 16:24:24| Process ID 20379
    2015/06/01 16:24:24| Process Roles: master worker
    2015/06/01 16:24:24| With 65536 file descriptors available
    2015/06/01 16:24:24| Initializing IP Cache...
    2015/06/01 16:24:24| DNS Socket created at [::], FD 5
    2015/06/01 16:24:24| DNS Socket created at 0.0.0.0, FD 6
    2015/06/01 16:24:24| Adding nameserver 127.0.1.1 from /etc/resolv.conf
    2015/06/01 16:24:24| Adding domain Home from /etc/resolv.conf
    2015/06/01 16:24:24| Logfile: opening log /home/john/squid3_log/access.log
    2015/06/01 16:24:24| WARNING: log parameters now start with a module name. Use 'stdio:/home/john/squid3_log/access.log'
    2015/06/01 16:24:24| WARNING: no_suid: setuid(0): (1) Operation not permitted
    2015/06/01 16:24:25| Unlinkd pipe opened on FD 11
    2015/06/01 16:24:25| Local cache digest enabled; rebuild/rewrite every 3600/3600 sec
    2015/06/01 16:24:25| Logfile: opening log /home/john/squid3_log/store.log
    2015/06/01 16:24:25| WARNING: log parameters now start with a module name. Use 'stdio:/home/john/squid3_log/store.log'
    2015/06/01 16:24:25| Swap maxSize 15360000 + 16384 KB, estimated 1182798 objects
    2015/06/01 16:24:25| Target number of buckets: 59139
    2015/06/01 16:24:25| Using 65536 Store buckets
    2015/06/01 16:24:25| Max Mem  size: 16384 KB
    2015/06/01 16:24:25| Max Swap size: 15360000 KB
    2015/06/01 16:24:25| Rebuilding storage in /home/john/squid3_cache (no log)
    2015/06/01 16:24:25| Using Least Load store dir selection
    2015/06/01 16:24:25| Current Directory is /home/john
    2015/06/01 16:24:25| Loaded Icons.
    2015/06/01 16:24:25| HTCP Disabled.
    2015/06/01 16:24:25| Sending SNMP messages from [::]:3129
    2015/06/01 16:24:25| WARNING: no_suid: setuid(0): (1) Operation not permitted
    2015/06/01 16:24:25| Pinger socket opened on FD 17
    2015/06/01 16:24:25| /var/run/squid3.pid: (13) Permission denied
    2015/06/01 16:24:25| Closing HTTP port [::]:3128
    FATAL: Could not write pid file
    Aborted (core dumped)
    

    I am using Ubuntu 14.04 LTS (Trusty Tahr) and the latest version of Squid3

    • heemayl
      heemayl about 9 years
      Please edit your question and add the output of namei -l /var/cache/squid3
    • John K
      John K about 9 years
      @heemayl I have edited it. And as I can see, all is root, and one is squid3? I have no idea what it means
    • heemayl
      heemayl about 9 years
      Check my answer.
  • John K
    John K about 9 years
    thanks, but it did not fix. And sorry for the super late reply