Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output file is owned by root #381

Closed
aporquez opened this issue Feb 19, 2017 · 3 comments
Closed

Output file is owned by root #381

aporquez opened this issue Feb 19, 2017 · 3 comments

Comments

@aporquez
Copy link

aporquez commented Feb 19, 2017

I'm using .net core to call the unoconv through Process.Start. The pdf file is being generated but the owner of the file is "root" even though I run the application as a normal user(current user). I also tried using the "convert" of ImageMagick and the owner of the generated file is the current user.

I'm using Ubuntu 16.10 and I installed unoconv using
sudo apt-get install unoconv

unoconv --version
unoconv 0.7
Written by Dag Wieers dag@wieers.com
Homepage at http://dag.wieers.com/home-made/unoconv/
platform posix/linux
python 3.5.2+ (default, Sep 22 2016, 12:18:14)
[GCC 6.2.0 20160927]
LibreOffice 5.2.2.2

    public class Program
    {
        public static void Main(string[] args)
        {
 	    // output is owned by root
	    ProcessStartInfo unoconv = new ProcessStartInfo("unoconv");
            unoconv.UseShellExecute = false;
            unoconv.CreateNoWindow = true;
            unoconv.Arguments = string.Format("-f pdf -vvv -o {0} {1} ", "/home/sa/Documents/test-doc.pdf", "/home/sa/Documents/test.doc");
            unoconv.RedirectStandardInput = true;
            unoconv.RedirectStandardError = true;
            Process.Start(unoconv).WaitForExit();

	    // output is owned by current user
	    ProcessStartInfo convert = new ProcessStartInfo("convert");
            convert.UseShellExecute = false;
            convert.CreateNoWindow = true;
            convert.Arguments = string.Format(@"-density 150 {0} {1}", "/home/sa/Documents/test-tif.tif", "/home/sa/Documents/test-tif.pdf");
	    convert.RedirectStandardInput = true;
            convert.RedirectStandardError = true;
            Process.Start(convert).WaitForExit();        
        }
    }

This is the console output:
Using office base path: /usr/lib/libreoffice
Using office binary path: /usr/lib/libreoffice/program
Selected output format: Portable Document Format [.pdf]
Selected office filter: writer_pdf_Export
Used doctype: document
Output file: file:///home/sa/Documents/test-doc.pdf

@aporquez
Copy link
Author

Using the terminal

unoconv -vvvv -f pdf -o test-doc.pdf test.doc
Verbosity set to level 4
Using office base path: /usr/lib/libreoffice
Using office binary path: /usr/lib/libreoffice/program
DEBUG: Connection type: socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext
Input file: test.doc
Selected output format: Portable Document Format [.pdf]
Selected office filter: writer_pdf_Export
Used doctype: document
Output file: file:///home/sa/Documents/test-doc.pdf

ls -l
-rwxrw-r-- 1 sa sa 82432 Feb 19 20:39 test.doc
-rw-r--r-- 1 root root 53338 Feb 19 23:23 test-doc.pdf

@aporquez
Copy link
Author

Found the problem. I'm missing the --preserve parameter.

@bertalanimre
Copy link

If I try to use the preserve option I get an error message. I still get myself the file, but the owner is still root:root. This is the error message:

sudo -u nginx unoconv --format=pdf --preserve --output=normalized.pdf sample.txt
Traceback (most recent call last):
  File "/bin/unoconv", line 1400, in <module>
    main()
  File "/bin/unoconv", line 1316, in main
    convertor.convert(inputfn)
  File "/bin/unoconv", line 1137, in convert
    self.preserve(inputfn, outputfn)
  File "/bin/unoconv", line 922, in preserve
    with open(outputfn, "a") as f:
IOError: [Errno 13] Permission denied: '/AAAA/BBBB/CCCC/....../normalized.pdf'

All the folders are owned by nginx:nginx and they have 777 permissions so I have no clue why is there no permission denied for unoconv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants