Can't access custom folder

Description

Hello,

First of all thanks in advance to anyone who will take some time to help me.

I’m running a fresh install of gitea on a debian server and I have troubles customizing it following this documentation.

First of all it says in the documentation :

You can check the CustomPath using gitea help. You can also find the path on the Configuration tab in the Site Administration page.

But when I type gitea help I get :

DEFAULT CONFIGURATION:
   AppPath:    /usr/local/bin/gitea
   WorkPath:   /usr/local/bin
   CustomPath: /usr/local/bin/custom
   ConfigFile: /usr/local/bin/custom/conf/app.ini

While the site administration page gives me this :
image

When I try to list these directories I get this :

user@server:~$ ls -la /usr/local/bin
total 134652
drwxr-xr-x  2 root root      4096 30 janv. 15:50 .
drwxr-xr-x 10 root root      4096 25 janv. 16:15 ..
-rwxr-xr-x  1 root root 137872608 30 janv. 15:50 gitea
user@server:~$ ls -la /var/lib/gitea
ls: impossible d'ouvrir le répertoire '/var/lib/gitea': Permission non accordée
user@server:~$ ls -la /var/lib
total 116
...
drwxr-xr-x  2 root          root          4096 28 févr.  2023 git
drwxr-x---  5 git           git           4096 30 janv. 15:50 gitea
...

For reference here is how I installed Gitea :

HOW I INSTALLED GITEA

# Downloading

wget -O gitea https://dl.gitea.com/gitea/1.21.4/gitea-1.21.4-linux-amd64

chmod +x gitea

wget -O gitea.asc https://dl.gitea.com/gitea/1.21.4/gitea-1.21.4-linux-amd64.asc

# Key verification

sudo apt install gnupg

gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2

gpg --verify gitea.asc gitea

# Git user creation

sudo adduser \
   --system \
   --shell /bin/bash \
   --gecos 'Git Version Control' \
   --group \
   --disabled-password \
   --home /home/git \
   git

# Directory structure creation (as root)

mkdir -p /var/lib/gitea/{custom,data,log}
chown -R git:git /var/lib/gitea/
chmod -R 750 /var/lib/gitea/
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea

# copied bin to final location

sudo cp gitea /usr/local/bin/gitea

# Autocomplete scripts

bash_autocomplete in /usr/share/bash-completion/completions/gitea

zsh_autocomplete in /usr/share/zsh/_gitea

Then here are my gitea.service and reverse proxy configurations :

GITEA.SERVICE + REVERSE PROXY

# Service creation

gitea.service [Service] block :

[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
#RuntimeDirectory=gitea
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

# Reverse Proxy

ProxyPreserveHost On
ProxyRequests off
AllowEncodedSlashes NoDecode
ProxyPass / http://localhost:3000/ nocanon

Then after all that I went to gitea URL and went through installation process which gave my this /etc/gitea/app.ini :

APP.INI

APP_NAME = (my app name)
RUN_USER = git
WORK_PATH = /var/lib/gitea
RUN_MODE = prod

[database]
DB_TYPE = postgres
HOST = (my bdd ip address)
NAME = giteadb
USER = gitea
PASSWD = (my bdd password in clear ???)
SCHEMA =
SSL_MODE = disable
PATH = /var/lib/gitea/data/gitea.db
LOG_SQL = false

[repository]
ROOT = /var/lib/gitea/data/gitea-repositories

[server]
SSH_DOMAIN = (my gitea domain)
DOMAIN = (my gitea domain)
HTTP_PORT = 3000
ROOT_URL = https://(my gitea domain)/
APP_DATA_PATH = /var/lib/gitea/data
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_JWT_SECRET = (a secret)
OFFLINE_MODE = false

[lfs]
PATH = /var/lib/gitea/data/lfs

[mailer]
ENABLED = true
PROTOCOL = SMTPS
SMTP_ADDR = (my smtp server address)
SMTP_PORT = (my smtp server port)
FROM = (my smtp server address)
USER =
PASSWD =

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = true
DISABLE_REGISTRATION = true
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
ENABLE_CAPTCHA = false
REQUIRE_SIGNIN_VIEW = true
DEFAULT_KEEP_EMAIL_PRIVATE = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = false
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS = noreply

[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false

[cron.update_checker]
ENABLED = false

[session]
PROVIDER = file

[log]
MODE = console
LEVEL = info
ROOT_PATH = /var/lib/gitea/log

[repository.pull-request]
DEFAULT_MERGE_STYLE = merge

[repository.signing]
DEFAULT_TRUST_MODEL = committer

[security]
INSTALL_LOCK = true

I must admit I’m a little bit confused here so here are some questions :

  1. Why are gitea help and site administration displaying different directories ?
  2. Is it the intended behavior to be unable to access/modify /var/lib/gitea unless we are user ‘git’ ?
  3. Generally speaking, did I do something wrong and if so what ?

Gitea Version

1.21.4

Git Version

2.39.2

Operating System

Debian 12

Database

PostgreSQL

Help shows examples. The other shows those configured on your system.

Based on the output you shared that appears to be an accurate statement.

Unless you had someone else break things for you, it is extremely likely that you have. While you have done an excellent job with providing detail, I have no idea what problem you are encountering, which makes it difficult to explain what you have done wrong.

Hi @linkp and thanks for your answer.

Do you mean “I don’t know why you’re having your problem ?” or “I don’t understand what your problem is ?”

If it’s the latter, then my issue is that I don’t know how to access the Custom Folder to my gitea installation :slight_smile: (my understanding is that I should access this folder to customize gitea’s appearance among other things).

1 Like

Technically both, but the latter was the driving factor. :smiley:

Thanks for sharing the detail about Custom Folder access. I have never had to use that folder. The only thing loctaed below that path in my installation is a symlink conf -> /etc/gitea/conf. The target directory contains my Gitea app.ini.

I mean, you would make those type of changes in your app.ini file in that is ostensibly within that folder, but I’m confused as to why you are having difficulty accessing it. Surely you have root or sudoer access, or you wouldn’t have been able to change the directory ownership to begin with.

Is there a reason (other than being an emacs user) why you haven’t just typed sudo vim /var/lib/gitea/custom/conf/app.ini?

Thanks @linkp and sorry for late answer.
I managed to access the folder and do some tests as the git user.

If anyone is stuck in the same way in the future, the only way around I found is to :

sudo -i to access custom folder and manage files in it, then once changes are done change files owner and permissions so that gitea can access the files :

chown -R git:git /var/lib/gitea/
chmod -R 750 /var/lib/gitea/

su - git as root to run commands as git if needed (for debug purposes)