file-permissions

How to check if a PDF is Password Protected or not

自作多情 提交于 2019-11-30 17:46:36
问题 I am trying to use iText's PdfReader to check if a given PDF file is password protected or not, but am getting this exception: Exception in thread "Main Thread" java.lang.NoClassDefFoundError:org/bouncycastle/asn1/ASN1OctetString But when testing the same code against a non-password protected file it runs fine. Here is the complete code: try { PdfReader pdf = new PdfReader("C:\\abc.pdf"); } catch (IOException e) { e.printStackTrace(); } 回答1: Use Apache PDFBox - Java PDF Library from here:

Check the permissions of a file in python

限于喜欢 提交于 2019-11-30 17:28:02
问题 I'm trying to check the readability of a file given the specified path. Here's what I have: def read_permissions(filepath): '''Checks the read permissions of the specified file''' try: os.access(filepath, os.R_OK) # Find the permissions using os.access except IOError: return False return True This works and returns True or False as the output when run. However, I want the error messages from errno to accompany it. This is what I think I would have to do (But I know that there is something

How to modify file access control in .NET Core

天涯浪子 提交于 2019-11-30 17:27:56
I'm trying to change the permissions of a file in .NET Core. However, it seems that FileInfo doesn't have any SetAccessControl anymore. // Create a new FileInfo object. FileInfo fInfo = new FileInfo(FileName); // Get a FileSecurity object that represents the // current security settings. FileSecurity fSecurity = fInfo.GetAccessControl(); // Add the FileSystemAccessRule to the security settings. fSecurity.AddAccessRule(new FileSystemAccessRule(Account, Rights, ControlType)); // Set the new access settings. fInfo.SetAccessControl(fSecurity); The goal is just to add execution right to the current

Reading /dev/cpu/*/msr from userspace: operation not permitted

元气小坏坏 提交于 2019-11-30 14:03:53
I am trying to write a simple application that can read msr registers, and am running this application from userspace. I have loaded the msr module and given read permissions for everyone to /dev/cpu/*/msr. But still the user is not able to access these files but the root can. The permissions look like this: crw-r--r-- 1 root root 202, 0 sep 6 17:55 /dev/cpu/0/msr crw-r--r-- 1 root root 202, 1 sep 6 17:55 /dev/cpu/1/msr crw-r--r-- 1 root root 202, 2 sep 6 17:55 /dev/cpu/2/msr crw-r--r-- 1 root root 202, 3 sep 6 17:55 /dev/cpu/3/msr I keep getting "Operation not permitted" error message when I

Possible to give “Network Service” on one computer permission to a directory on another computer?

可紊 提交于 2019-11-30 12:00:43
I have a file: \\Computer1\Share\file.pdf and I need to open in using a service running as the network service account on another computer: Computer2\NETWORK SERVICE FWIW, Both Computer1 and Computer2 are on the same domain Domain1 Is it possible to accomplish this task? Joe U Yes. If both servers are on the same domain then you can enable access to the share for Domain1\Computer2$ (where Computer2$ represents Network Service on Computer2). If it were me, I'd use a domain account to run the service and grant that same domain account the appropriate permissions on the remote computer. I don't

PHP/Apache Deny folder access to user but not to script

*爱你&永不变心* 提交于 2019-11-30 10:16:12
So I have this php web app, and one of my folder contains some files that can be downloaded. I have a download script that modifies the headers, in order to always offer a download link. (instead of showing a picture for example, when you click on a link, a download box pops out) Right now, if you enter a url like: http://www.mywebsite.com/content/ You get the listing of all the downloadable files, and of course, you can just download them all, without going through the website interface. Personally, I don't think it's a problem, since I often use downthemall or other downloading tool, and

PHP File_put_contents not working

℡╲_俬逩灬. 提交于 2019-11-30 10:01:27
问题 Check this code: <?php $url = 'http://www.example.com/downloads/count.txt'; $hit_count = @file_get_contents($url); $hit_count++; @file_put_contents($url, $hit_count); header('Location: wmwc.zip'); ?> @file_get_contents is working fine and the header location change to the downloaded file also works, but either the hit_count increase or @file_put_contents isn't working, because the number with the file doesnt increase by 1. I've set the file permission to 777, but when I try to set the

fopen Permission denied on a file with 777 permissions

白昼怎懂夜的黑 提交于 2019-11-30 09:12:49
问题 Since the title of this post is pretty much self-explanatory, I'll just jump to the code : echo sprintf('%o', fileperms('test.txt'))."<br/>"; fopen("test.txt", "w"); And with this I get : 100777 fopen(test.txt): failed to open stream: Permission denied Any ideas ? Edit : Problem solved : there were access control lists on the server that were not configured correctly. Thanks ! 回答1: I think its possible that you have write/read permissions on the file but not on the folder. Try this in the

How can I programmatically determine if I have write privileges using C# in .Net?

女生的网名这么多〃 提交于 2019-11-30 08:45:39
问题 How can I determine if I have write permission on a remote machine in my intranet using C# in .Net? 回答1: The simple answer would be to try it and see. The Windows security APIs are not for the faint of heart, and may be possible you have write permission without having permission to view the permissions! 回答2: Been there too, the best and most reliable solution I found was this: bool hasWriteAccess = true; string remoteFileName = "\\server\share\file.name" try { createRemoteFile(remoteFileName

Set File Permissions in C#

北战南征 提交于 2019-11-30 08:36:00
问题 I wanna set the permissions on a file to "can not be deleted" in C#, only readable. But I don't know how to do this. Can you help me ? 回答1: Take a look at File.SetAttributes(). There are lots of examples online about how to use it. Taken from that MSDN page: FileAttributes attributes = File.GetAttributes(path); if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { // Show the file. attributes = RemoveAttribute(attributes, FileAttributes.Hidden); File.SetAttributes(path,