Changing file permissions of unowned files in linux - linux

I've written some code in C that needs to change a file modification time using utime(),
but I get permission error.
Is there a way changing file permissions even though I'm don't own the file?
Thanks in advance for any help.

Yes, be root. Linux by default doesn't have a fine-grained security model. Either you're root and have all rights, or you're a regular user and have only rights to your own stuff.

Related

Drupal 8: How to use private file system for node

Scenario:
I want to create a field field and attach it to a content type and willing to store the uploaded file into private file system.
I am using Drupal 8.6, php 7.1 and linux
My default file system is public, but for that specific file field, I want to store it, into private folder. So I created a folder outside my document root folder e.g. /var/www/private and set that into settings.php.
The purpose of this field is that, to allow, certain logged in users to able to download and restrict other.
I googled a lot, there are lot of suggestions, none worked or pointed the issue I am facing. I set the file directory as "dcouments/[date:custom:Y]-[date:custom:m]".
Now when i trying to upload a file, it gives me error like, folder "documents/2018-09" can't be created and upload failed. Surely it seems permission issue, i gave "private" folder to "rwxrwxr-x" permission, but its not working. Strangely it works in windows system.
Could anyone suggest, how to fix that? Whats going wrong there?
thanks in advance!
Permissions you defined may just be fine. The problem maybe that the private folder doesn't belong to www-data neither to its group. Check the real owner of the folder and set it to www-data. This should do the trick.
What I actually find out that, the web-server don't have permission to create sub-directory in the private folder.

sp_session_create crashes in libspotify.dll 12.1.51 for win32 x86

For some users, the libspotify crashes when calling sp_session_create.
All config parameters are set except the proxy settings which are NULL.
The crash occurs at libspotify+0xdc7c0
I have minidumps available.
I have found this to be a permissions issue. If the user does not have permissions to create (and/or modify) the settings and cache directories passed to sp_session_create, it will helpfully crash. I think that a helpful error code with no crash would have saved me an awful lot of time.
The solution is to make sure the settings and cache directories can be created (if they do not exist) and that they are writable by the current user. This could be achieved either by directly modifying directory permissions or by changing the location of those directories to somewhere else (eg the user's AppData directory).
I should mention that I use the same directory for both (in case that wasn't already obvious), and I haven't bothered to isolate which is responsible for the crash.
Anyway, on Windows 8 this was a problem when a program was installed under the Program Files directory and my settings/cache was a relative path off that. The users by default did not have sufficient privileges.
Hope this helps.

How do I get access to system32?

I have been trying to delete a file in "System32" because all it does is a useless popup.
However, whenever I try to delete the file, it says that I need permissions from TrustedInstaller.
How do I get permissions to that file?
You don't have permission to delete any file in your file system. Some are system files and may cause your Windows to error if missing. Windows does not allow you to delete these.
Note that some files that you do have permissions to delete, may cause your system to become unstable. In general, you should be really careful with deleting files inside Windows folder. Do your research, ask people about your specific file and whether it's safe to delete it (or know the consequences). If you decide to, be sure to make a backup of your system prior to any changes.

vftpd issue regarding file permissions and user rights

My system is:
Ubuntu 10.04 / Apache2
The question is related to the sofware vftpd - an ftp server for linux (https://security.appspot.com/vsftpd.html)
I have installed vftpd and it works fine. I am having an issue though trying to understand why users are able to delete files which are owned by root. I have set up the ftp server with the option "local_enable=YES" and also "chroot_local_user=YES" so that the users cannot navigate outside their home directory.
The strange thing is that if a file is owned by root, the ftp users are able to delete it. Is a user able to delete any file in the home directory regardless of who owns it?
I want to prevent users from being able to delete files, or allow other users to only have read access to the home directories of other users.
If anyone knows the vftpd software and can help i´d be most grateful,
yours,
Rob
Have you checked which is the chmod of the files? If all files belongs to the same group, and the group have read and write privileges, any user can modify the files through ftp.

Windows 7 Security Policy: How Do I Allow My .NET App to Write to Drive "C:"?

My application is not supposed to perform any administrative tasks, so I want a normal User account to be able to run it. Only thing is, my application reads from and writes to a database file; if the user running Windows 7 (Or Vista) installs my app in drive C, the drive's default permission set configuration doesn't allow my app to write data.
How can I allow my app to write to C:, without requiring full administrative privileges?
If the database file exists at install time you can just grant the user write access to the file as part of the installation process (ordinary users do not have this permission by default). If the file needs to be created by the program the user running the program will need modify permissions on the c drive, which is not something that I would recommend.
I'd suggest storing your db file in Documents and Settings / App data / your app / directory. It exists specifically for this purpose. Writing to C:/Program Files is not so good practice. If that's possible in your case, that is.
You need to open UAC (User Account Access) and set security slider to the bottom. Then you can access drive C: as you did in windows XP.
I decided to modify directory permissions in the setup process, so I created an .exe file that changes the permissions of its start-up path, and gives all users access to that path. I simply included that .exe file in my deployment project, and created a Custom Action that would run the file in the Commit phase of installation.
Because the setup asks the user for administrative rights when it is being installed, my .exe also enjoys administrative privileges and can modify the permissions of the installation directory.
In my .exe, I used a Process instance to run the ACL utility shipped with Windows (icacls.exe) as follows:
ICACLS.EXE [TargetDir] /T /C /grant Users:F
(Make sure that [TargetDir] doesn't end with a "\" or the call will fail.)
This gives all users full control access to the target directory.
I could also write .NET code and change directory permissions manually, but I'm a little lazy!
You may however want to inspect your environment conditions thoroughly so that what you do wouldn't become a security hole in your environment; but this was suitable for me.
I hope this helps others who faced the same issue.
The user by default should have write permissions to drive C:, if not, then you will need to change the directory you read from and write to, to the executing directory (C:/Program Files/Your App/) rather than the root of C:
You can get this by
String Path = Path.GetDirectoryName(Application.ExecutablePath);

Resources