0
chmod 777 ./myapp

Why do i need to provide chmod 777 to myapp after every publish. Without providing permissions the result of ./myapp is: Permission denied. Even when logged in using root user.

Are there any alternatives to do this?

Harit Kumar
  • 2,272
  • 2
  • 12
  • 24
  • 3
    Whatever problem it is that you are trying to solve, **giving other users write access to your program is a *serious* security flaw** and an antipattern. You need to understand the permission model and grant the permissions which the problem requires but absolutely no more (typically 755 for a script or 711 for a directory which users need to access but not read). – tripleee Sep 29 '17 at 08:38
  • 2
    What version of .NET Core are you using? Sounds like you are hitting https://github.com/dotnet/sdk/pull/1338 – omajid Sep 29 '17 at 17:23
  • I am using .NET Core 2.0 and issue looks same. – Harit Kumar Oct 01 '17 at 18:42

1 Answers1

1

Whatever is "publishing" the app needs to write it with the correct permissions. You are not showing us how you are doing that so we can't tell you what exactly is wrong, but something like

chmod 755 myapp   # only really required the first time
scp myapp prod:/srv/myapp/

If you are using a version control system like Git, the permissions change is a change you need to commit in order to preserve it.

chmod 755 myapp
git add myapp
git commit -m "fixed permissions" myapp

Now every check-out should have the correct permissions and you can forget about this until next time you start a new project.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Possibly I am revealing my complete ignorance about .Net -- maybe "publish" has a specific and very precise meaning there. But the basic idea probably still holds. – tripleee Sep 29 '17 at 08:41