Failed to open file: Permission denied? - file

I am running logstash-1.4.1 on Ubuntu and get the following error:
failed to open /home/Desktop/Input/2014-10-02/abc.log: Permission denied - /home/Desktop/Input/2014-10-02/abc.log {:level=>:warn, :file=>"filewatch/tail.rb", :line=>"107"}
Background:
I copied the directory structure of logs from a remote server to my local machine. Now, on running logstash on my local machine on the directory structure I copied, this error occurs.
When I check permissions on the file, it's showing both read write.
Any idea?
As I now checked the logstash console, it's evident that logstash is opening some files and after that permission denied starts coming till end.
CONSOLE:
_open_file: /home/Desktop/Input/2014-10-11/abc.log: opening {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"98"}
/home/Desktop/Input/2014-10-11/abc.log: initial create, no sincedb, **seeking to beginning** of file {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"133"}
_open_file: /home/Desktop/Input/2014-10-21/abc.log: opening {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"98"}
/home/Desktop/Input/2014-10-21/abc.log: initial create, no sincedb, **seeking to beginning** of file {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"133"}
_open_file: /home/Desktop/Input/2014-11-04/abc.log: opening {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"98"}
failed to open /home/Desktop/Input/2014-11-04/abc.log: **Permission denied** - /home/Desktop/Input/2014-11-04/abc.log {:level=>:warn, :file=>"filewatch/tail.rb", :line=>"107"}
_open_file: /home/Desktop/Input/2014-10-10/abc.log: opening {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"98"}
failed to open /home/Desktop/Input/2014-10-10/abc.log: **Permission denied** - /home/Desktop/Input/2014-10-10/abc.log {:level=>:warn, :file=>"filewatch/tail.rb", :line=>"107"}
Is it because of some limit might be there to number of files opened, as logstash is opening files till a limit and after that gives permission denied errors??
My file permissions for files it gives permission denied error:
ls -l ./Input/2014-11-04/abc.log
-rw-rw-r-- 1 userA userA 0 Nov 12 09:56 ./Input/2014-11-04/abc.log
ls -ld ./Input/2014-11-04
drwxrwxr-x 3 userA userA 4096 Nov 12 09:56 ./Input/2014-11-04
ls -l /home/Desktop/Input/2014-10-10/abc.log
-rw-rw-r-- 1 userA userA 0 Nov 12 09:56 /home/userA/Desktop/Input/2014-10-10/abc.log
ls -ld /home/Desktop/Input/2014-10-10
drwxrwxr-x 2 userA userA 4096 Nov 12 09:56 /home/Desktop/Input/2014-10-10
EDIT:
Logstash is run using userA.
Detailed File Permissions:
ls -ld /home/
drwxr-xr-x 3 root root 4096 Aug 27 2013 /home/
ls -ld /home/Desktop/
drwxr-xr-x 7 userA userA 4096 Nov 12 12:45 /home/Desktop/
ls -ld /home/Desktop/Input/
drwxrwxr-x 47 userA userA 4096 Nov 12 10:50 /home/Desktop/Input/
ls -l /home/Desktop/Input/abc.log
-rw-rw-r-- 1 userA userA 0 Nov 12 09:56 /home/Desktop/Input/abc.log

Related

what is the .stt file used for in TDengine database?

what is the .stt file used for in TDengine database ?
under the dataDir some of the file is called .stt like this :
ssn#TDengine:/var/lib/taos/vnode/vnode14$ cd ..
ssn#TDengine:/var/lib/taos/vnode$ ls -ltR | grep -i stt
-rwxrwxrwx 1 root root 4096 Jan 11 10:19 v18f1736ver22.stt
-rwxrwxrwx 1 root root 4096 Jan 11 10:19 v19f1736ver16.stt
-rwxrwxrwx 1 root root 4096 Jan 10 20:00 v16f1736ver18.stt
-rwxrwxrwx 1 root root 4096 Jan 10 20:01 v17f1736ver27.stt
may I know what is it for ?
a specific description for this file ,what is it used ,does it impact the database performance,etc.
the .sst file is equivalent to the .last file in the TDengine database 2.0
it is used to store the data fragment that smaller than minrows configuration .

How to destine the configure generated files to special path?

How to destine the configure output files path?
in some case I only can configure like this:
/root/src/my_software-1.8.2/configure
in my case, I can not cd into /root/src/my_software-1.8.2/.
I will generate these files to /:
2 00:06 ..
-rwxr-xr-x. 1 root root 0 Sep 27 07:32 .dockerenv
-rw-r--r--. 1 root root 24790 Oct 2 00:06 Makefile
drwxr-xr-x. 2 root root 53 Sep 28 11:24 att
lrwxrwxrwx. 1 root root 7 May 11 2019 bin -> usr/bin
-rw-r--r--. 1 root root 3934 Oct 2 00:06 config.h
-rw-r--r--. 1 root root 31584 Oct 2 00:06 config.log
-rwxr-xr-x. 1 root root 33874 Oct 2 00:06 config.status
I want destine these generated files to special output path(/root/src/my_software-1.8.2/)? how?
EDIT-01
In fact, I use the command to execute script:
docker exec -it centos-03 "my command"
but I can not execute the compound command like this:
docker exec -it centos-03 "cd /root/src/my_software-1.8.2/;./configure"
so I want use one command to do that.

Choose BSD or sys5 style when creating file in linux

When I create file in linux default group owner becomes gid of process which creates file. If I add SGID to parent directory file will inherit parent directory owner group. Also I can change fs mount options to behave either like sys5 or like BSD.
What if I want to choose this option regardless directory permissions and fs mount options? Is there c function option or syscall parameter which allows you to choose group owner?
$ find . -ls
262 4 drwxrwxr-x 4 devops devops 4096 Apr 24 18:01 .
999 4 drwxrwxr-x 2 devops root 4096 Apr 24 18:03 ./dir1
6093 4 drwxrwsr-x 2 devops root 4096 Apr 24 18:03 ./dir2
$ touch dir1/file dir2/file
$ find . -ls
262 4 drwxrwxr-x 4 devops devops 4096 Apr 24 18:01 .
999 4 drwxrwxr-x 2 devops root 4096 Apr 24 18:04 ./dir1
5576 0 -rw-rw-r-- 1 devops devops 0 Apr 24 18:04 ./dir1/file
6093 4 drwxrwsr-x 2 devops root 4096 Apr 24 18:04 ./dir2
6094 0 -rw-rw-r-- 1 devops root 0 Apr 24 18:04 ./dir2/file
$
And I wish to have something like that:
$ mytouch -s BSD dir1/file1
$ mytouch -s sys5 dir1/file2
$ find dir1 -ls
999 4 drwxrwxr-x 2 devops root 4096 Apr 24 18:10 dir1
6213 0 -rw-rw-r-- 1 devops root 0 Apr 24 18:10 dir1/file1
6214 0 -rw-rw-r-- 1 devops devops 0 Apr 24 18:10 dir1/file2
$
Chances are, you can't.
The implementation of sticky bits exists entirely within the kernel, and there are no options to open() or creat() which control how it operates.
Your program could conceivably call chown() to manually reset the group of the file after creating it. However, this would only work reliably if your process is running as root, or as a member of the group that owns the parent directory.

Abort BGSAVE Already in process

I started saving redis-db snapshot by calling BGSAVE command in redis-cli.
It has started running but I keep getting these errors in the logs
[30853] 27 Jan 07:18:41.129 # Background saving error
[30853] 27 Jan 07:18:47.043 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:47.058 * Background saving started by pid 13204
[13204] 27 Jan 07:18:47.058 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:47.158 # Background saving error
[30853] 27 Jan 07:18:53.070 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:53.085 * Background saving started by pid 13207
[13207] 27 Jan 07:18:53.085 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:53.186 # Background saving error
[30853] 27 Jan 07:18:59.098 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:59.113 * Background saving started by pid 13210
[13210] 27 Jan 07:18:59.114 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:59.213 # Background saving error
looks like the redis BGSAVE command is running indefinitely. How to stop this.
Also I tried checking for process pid by ps -aux| grep redis command.
13196 pts/11 S+ 0:00 grep --color=auto redis
30853 ? Ssl 1292:57 /usr/bin/redis-server *:6379
There is no process to kill.
EDIT: These are the permissions to redis folder and dump.rdb file
f: /var/lib/redis
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x redis redis redis
f: /var/lib/redis/dump.rdb
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x redis redis redis
-rw-rw-rw- redis redis dump.rdb
EDIT2: Got the answer. The problem was somehow the config parameters are changed. The dbfilename and dir values are changed.
Set these values to original through CONFIG SET command and now its working fine. Adding in-case somebody has same problem.
But the question is how did they change. Did this happen to anybody else?
Help me
Thanks
You can either try and fix the file permissions error (does the default save location exist and does redis have permission to write to it?) or you can disable saving with:
config set save ""

"bare linefeeds received in ASCII mode" warning when listing directory on my FTP server

I am creating an FTP server as a school project, most of the commands are working and I almost nailed PORT (active mode for data transfer).
Launching my server using ftp like such:
ftp localhost 4242 // where 4242 is the port on which my server is listening
And using the command ls after logging in, I receive a working ls output followed by this message:
WARNING! 8 bare linefeeds received in ASCII mode
File may not have transferred correctly.
Please note that when using ls in ftp, it switches automatically to Active Mode before using the LIST command.
What does this error signify?
Full output:
200 Active Mode Enabled.
150 Directory listing.
total 56
drwxrwxr-x 4 kade_c kade_c 4096 mai 12 15:24 .
drwxr-xr-x 38 kade_c kade_c 4096 mai 12 14:58 ..
drwxrwxr-x 8 kade_c kade_c 4096 mai 12 15:17 .git
-rw-rw-r-- 1 kade_c kade_c 1726 mai 11 10:35 Makefile
-rw-rw-r-- 1 kade_c kade_c 161 mai 11 11:43 README.txt
-rwxrwxr-x 1 kade_c kade_c 29368 mai 12 15:24 server
drwxrwxr-x 4 kade_c kade_c 4096 mai 2 18:40 server_src
WARNING! 8 bare linefeeds received in ASCII mode
File may not have transferred correctly.
226 LIST complete.
And finally, here is the part of the code that creates, and connects to the socket and does the ls -la:
server_write(client, "150 Directory listing.\r\n");
if (connect_data(client) == -1) // Creates socket and connects to it
{
server_write(client, "520 Impossible to reach client.\r\n");
return;
}
ofd = xdup(1);
xdup2(client->data.socket, 1);
system("ls -la");
xdup2(ofd, 1);
server_write(client, "226 LIST complete.\r\n");
close_data(client, -1);
This issue is because you are downloading files in ASCII mode. Switching to binary mode will make the warning disappear.
Once you login to the FTP server, type binary and then start downloading.
ftp> binary
200 Type set to I.
You only have to run this command once per FTP session.
I'd guess that you send LF's to the client, and the client (rightly) expects CRLF's and warns about those missing CR's.
According to FTP specification, RFC 959, section 3.4. Transmission modes, in the ASCII mode, you need to use CRLF exclusively:
For the purpose of standardized transfer, the sending host will
translate its internal end of line or end of record denotation
into the representation prescribed by the transfer mode and file
structure, and the receiving host will perform the inverse
translation to its internal denotation. ... End-of-line in an ASCII file with no
record structure should be indicated by <CRLF>

Resources