mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 10:39:38 -05:00
Gitea cannot start with a read-only config #2743
Closed
opened 2025-11-02 04:46:18 -06:00 by GiteaMirror
·
44 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
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c1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
issue/needs-feedback
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#2743
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @captn3m0 on GitHub (Jan 11, 2019).
[x]):Description
Running with the exact same configuration and on 1.6 latest docker image does not give this error.
The configuration file does have the following lines:
@captn3m0 commented on GitHub (Jan 11, 2019):
The secret is exactly 32 characters encoded in base64, and it works perfectly if I switch the image to 1.6
@bkraul commented on GitHub (Jan 11, 2019):
I think my issue is related. gitea/gitea:latest broke my install, apparently when it cannot migrate, because it is getting "permission denied", eventhough the app.ini file is owned by user git (as it should be). The log keeps showing this repeatedly.
Everything works fine when I revert to tag 1.6.
EDIT: Take that back...on one of my installs, even with 1.6 the installation is hosed (same repeated messages as above). What is going on??
@captn3m0 commented on GitHub (Jan 12, 2019):
I'm currently running with LFS disabled and it does indeed work (as someone already mentioned):
18164d175eBut if you are using LFS and have a secret already in your config, 1.7 breaks your config and overwrites it.
@bkraul commented on GitHub (Jan 12, 2019):
In my case, setting LFS off does nothing. The install is still broken. Seems mine is unrelated in the sense that it doesn't relate to LFS. Opened #5708 .
@zeripath commented on GitHub (Jan 13, 2019):
Hmm... is this still broken since this commit:
9e9d1b8f95?@captn3m0 commented on GitHub (Jan 14, 2019):
Tested against
:latestdocker image (8d40032), and it seems to be fixed.@zeripath commented on GitHub (Jan 14, 2019):
Cool. Sorry about that.
We need to add an integration test that takes a Gitea db from the minimal version and a few choice other versions and migrates it. That way we'll know if there's an issue in migration quicker.
This would be a quick pr I think.
@MrFloppy commented on GitHub (Jan 15, 2019):
Unfortunately :latest docker image from 14.01.2019 still is broken with the permission denied error on the app.ini for me. Reverting to 1.6 makes it run still fine.
Is there something like a "stable" channel?
@captn3m0 commented on GitHub (Jan 15, 2019):
1.6.3is the last stable release.1.7is still in RC.I double checked after your comment, and switching to
:latestwith LFS turned on broke my setup again. So I'm running with LFS disabled on LFS for now. (The container exited, but didn't have any logs so I need to investigate this a little bit more).@bkraul commented on GitHub (Jan 15, 2019):
Not sure what is happening with your setup, but I have
LFS_START_SERVER = truein 2 of my installations and have it working OK on :latest (270fa6d). I can also see theapp.inifile's permissions being set to the proper user on container start (changed them to a different user on the host and they were changed by the container after it starts) so this may not be an issue of permissions of that particular file. Of course, I could be wrong.Please pardon my ignorance, but where is
${lfs-jwt-secret}coming from? Mine has an actual secret string.@captn3m0 commented on GitHub (Jan 15, 2019):
It gets rendered in via terraform: https://git.captnemo.in/nemo/nebula/src/branch/master/gitea/data.tf#L13-L23, which uploads it as a file inside the container.
I'll try to switch LFS back on and see if I can get an error code or some logs out it tomorrow.
@bkraul commented on GitHub (Jan 15, 2019):
Might I add that I am running the stack on my server with docker-compose as root. I do not know if this matters, but I have never tried any other way to do with docker-compose. Obviously, inside the container, the user that runs the app is the default (
gitea 1000). Perhaps that might have something to do with this.@captn3m0 commented on GitHub (Jan 21, 2019):
Okay, now my setup is borked in the same way as @bkraul
Keeps on repeating the same logs. Switching on debug logs does give some information:
Edit: This looks like a known issue: #5759
Will close this issue once I can get past that.
@bkraul commented on GitHub (Jan 21, 2019):
@captn3m0, workaround explained in #5681 . Basically, you connect to the MySQL/MariaDB DB and set the theme column in the user table for all the users as
'gitea', then reattempt to start. This, for me was a little inconvenient because I had it running in a stack where it wasn't publicly available, so I had to temporarily make it available to fix.After setting that up, everything worked fine with the latest version.
@captn3m0 commented on GitHub (Jan 21, 2019):
My nemesis was #5759 (I made the
themechange, but it doesn't help).Finally fixed it by running all the sqlite commands in migrations/78 manually and bumping the version to 79.
@captn3m0 commented on GitHub (Jan 21, 2019):
Turned back
LFS_START_SERVER = trueon:latestand it breaks still.@zeripath commented on GitHub (Jan 22, 2019):
Does your app.ini still have:
LFS_JWT_SECRET = ${lfs-jwt-secret}?Rather than an actual jws secret in it?
@captn3m0 commented on GitHub (Jan 22, 2019):
No it doesn't.
It gets rendered by Terraform, so gitea gets the actual secret:
Right now set to false to keep the server running. The server is up at https://git.captnemo.in, happy to give you temporary admin access if you signup.
@zeripath commented on GitHub (Jan 22, 2019):
So, in your testing if LFS is set to true, do you get anything in the logs?
I'm just asking so that it's easier to look for the misbehaving code.
@zeripath commented on GitHub (Jan 22, 2019):
Ah sorry just noticed the above
@captn3m0 commented on GitHub (Jan 22, 2019):
I've switched to log level Trace, but it doesn't get me anything more.
@typeless commented on GitHub (Jan 22, 2019):
@captn3m0 how about
docker exec my-gitea-container stat /my/custom/conf/app,ini@zeripath commented on GitHub (Jan 22, 2019):
Ok there's two places that error is printed:
1bb22b2b47/modules/setting/setting.go (L947)1bb22b2b47/modules/setting/setting.go (L986)Line 986 can only be reached if INTERNAL_SECRET is empty and stopping LFS would have no effect on that.
Line 947 is therefore the culprit. This can only be reached depending on the results of
1bb22b2b47/modules/setting/setting.go (L923)If
errisn'tnilornisn't32.Ok are you sure that base64 URLDecoded your LFS value is 32 and that it's valid?
@captn3m0 commented on GitHub (Jan 22, 2019):
I'd gotten to the same root cause, and mentioned this above:
https://github.com/go-gitea/gitea/issues/5704#issuecomment-453633387
@captn3m0 commented on GitHub (Jan 22, 2019):
@zeripath commented on GitHub (Jan 22, 2019):
Actually looking at that file I'm not sure that I see
LFS.JWTSecretBase64is set read/set anywhere...@typeless commented on GitHub (Jan 22, 2019):
The
Dockerfileshows thatgitearuns as the usergitrather thanroot.So, it's reasonable that it cannot write the file.
Edit: A possible cause is that the
app.iniis mapped from the host machine which belongs to a particular user. But the UID/GID of the file does not exist in/etc/passwd.I don't run Gitea with Docker, but I guess people who do that have an idiomatic way to deal with such problem?
Edit2: @zeripath Re-read your earlier comment and I can understand what you mean now.
@zeripath commented on GitHub (Jan 22, 2019):
I'm not at a dev box. Are you able to diff
modules/setting/setting.gobetween master and v1.6 and see if there are changes related to this.@zeripath commented on GitHub (Jan 22, 2019):
@typeless he doesn't want Gitea to write to that file, and for some reason it is despite having a good config that should mean it doesn't need to write to the file.
Primarily Gitea is writing to app.ini because it can't find a valid jwt token for LFS but there is one in the app.ini.
@zeripath commented on GitHub (Jan 23, 2019):
OK, so I've looked at this again. Looking at
modules/setting/setting.go:Now the
err = sec.MapTo(&LFS)should sets the values ofLFSincluding theJWTSecretBase64and testing on master with a simple change it certainly does.So I think we're back to the original:
erris either notnilornis not equal to32Basically your JWT secret is not correct. Now that code hasn't changed so I don't understand why it was working for you on 1.6
How can we work around this?
I suggest you regenerate a JWT Secret and see if that fixes your problem. If it does - then you can post your old JWT secret and we can test it or you can use the playground I've put in here to test your secret:
https://play.golang.org/p/GhUV1waCX6i
@captn3m0 commented on GitHub (Jan 24, 2019):
Thanks a lot for sticking with me on this. Looks like my secret is incorrect after all. I think I screwed up when I made the check last time and checked some other secret. I'll file a PR for the documentation, it needs to mention base64 (and how to generate a valid secret)
However, I'm unable to still generate a valid secret that decodes to 32 bytes.
I've tried
openssl rand -base64 32as well asopenssl rand 32 | base64 -w 0and neither seems to work correctly in the playground. My shell says 32 bytes for both:@zeripath commented on GitHub (Jan 24, 2019):
It's not just base64 it's RawURLencoded base64
@captn3m0 commented on GitHub (Jan 24, 2019):
I tried generating it with go: https://play.golang.org/p/VeLnNm8piDY
Still can't get it to work.
@micw commented on GitHub (Feb 12, 2019):
I still have the issue with "latest" which is <1 hour old.
I create the config as kubernetes ConfigMap, so it's read-only. In my logs I see lots of
The secret I set (for testing purpose, not my actual secret) is LFS_JWT_SECRET = ZbVOMOq1jKet3XH2UvIS1gTB4C-nVz2dJCIR37J61wQ
I have reviewed the current master code and tried to reproduce that: https://play.golang.org/p/RT4Sn4KOusH - on that test it seems to work properly.
@micw commented on GitHub (Feb 12, 2019):
Update: Figured out that it was the "INTERNAL_TOKEN", not the LFS token it tried to write.
@micw commented on GitHub (Feb 12, 2019):
I ended up in mounting the config at a different location and copy it on container startup.
@micw commented on GitHub (Feb 12, 2019):
A possible option to solve this issue would be to put the secrets into a different file (secrets.ini).
@lunny commented on GitHub (Feb 28, 2019):
After you fill all the necessary items, it should be read-only. Otherwise, you have to fill even database config items.
@nodiscc commented on GitHub (Mar 5, 2019):
I hit the same problem while trying to deploy gitea with ansible with a read-only
app.ini. It would be nice to document how to manually generate the secrets in the config file (using shell commands or python for example). As far as I can see the secrets that must be generated are:LFS_JWT_SECRET: 32 character key, encoded with unpadded base64. How to generate: ??? (Edit: not required)SECRET_KEY: 64 character key. How to generate:openssl rand -hex 64INTERNAL_TOKEN: ???@lunny commented on GitHub (Mar 17, 2019):
You can visit https://docs.gitea.io/en-us/command-line/ and find
generate->secretcommand to do that.@nodiscc commented on GitHub (Mar 17, 2019):
Gitea is now running properly with a read-only config file for me. Indeed the solution was to generate
INTERNAL_TOKENusinggitea generate secret INTERNAL_TOKEN. You can find my install procedure (using ansible) here@lunny commented on GitHub (Mar 17, 2019):
So let's close this issue. Please feel free to reopen it.
@nodiscc commented on GitHub (Mar 17, 2019):
I submitted https://github.com/go-gitea/gitea/pull/6348 to document this a bit more.
@captn3m0 commented on GitHub (Jun 2, 2019):
A recent release enable
oauth2, which means gitea will now try to generate a oauth JWT secret, and fail on the upgrade. Took me a while to figure out, because the error message doesn't say that the JWT is for oauth. (justerror saving generating JWT secret).Either disable
oauth2or generate a new JWT secret and put it in the oauth2 block for a fix.