Create user in Yocto - sockets

I used Yocto useradd-example.bb to create two users on my embedded device. ( all 755 )
Now when I log in as user I can't open socket even above port 1024. It fails with error (socket: Permission denied)
I tried to use setcap to add capability ( like 'cap_net_bind_service ) but it didn't help.
Is it something wrong with the permission there ?

Related

PostgreSQL: Error importing csv file from shared network folder

My goal is to import csv file to postgresql database.
my file is located in network shared folder and I do not have no option to make it in a local folder.
My Folder located in :
"smb://file-srv/doc/myfile.csv"
When I run my this PostgreSQL script:
COPY tbl_data
FROM 'smb://file-srv/doc/myfile.csv' DELIMITER ',' CSV;
I would get this error :
ERROR: could not open file "smb://file-srv/doc/myfile.csv" for reading: No such file or directory
SQL state: 58P01
I have no problem to access the file and open it.
I am using PostgreSQL 9.6 under Ubuntu 16.04.
Please Advice how to fix this problem.
Update
When I try to access the file with postgres user I would have same error:
postgres#file-srv:~$$ cat smb://file-srv/doc/myfile.csv
cat: 'smb://file-srv/doc/myfile.csv' : No such file or directory
As I mention when I user mounted folder I created I can access the file.
it is about permission. you have to check read access on file and folders.
also, logging with superuser access may solve your problem.
In short, this is a permissions issue: Your network share is likely locally mounted to your user's UID, while the PostgreSQL server is running as the postgres user.
Second, when you log into your database, there is not an overlap between the database's users and the system's users, even if you have the same username. This means that when you request a file from your network share, the DB user, in this case postgres, does not have the necessary permissions.
To see this, and assuming you have root access on the box in question, you might try to become the postgres user and see that you cannot access the file:
$ sudo su - postgres
$ cat /run/user/.../smb.../yourfile.csv
Permission denied
The fix to your issue will involve -- somehow -- making the file or share accessible to the postgres user. Copying is certainly the quickest way. But that's off the table. You could mount the share (perhaps as read only) as the postgres user. You might do this in fstab.
However, unless this is going to be an automated detail that happens regularly, this seems like heroics. Without more information as to why you can't copy locally, I suggest copying the file locally.

Chef insufficient Permissions error on file resource

I have a file, let say xyz.sh, mounted from different file system on centos and root user does not have access to change the permissions of the file.
Current permissions are 755 for the file.
My cookbook's file resource checks for the permissions and if it is not 755 then change it to 755.
When I run the cookbook as root user it is giving an exception as 'Insufficient Permissions'.
Now I would have expected this exception if the file had some different permissions and chef tried to change it but not able to do that, but here as permissions are same as expectation, then why am I getting this exception?
Please help me!
Root is supposed to have permission to access any file in most cases (give or take some retrofits of the Unix filesystem model like POSIX ACLs). Regardless, just remove the mode property from the resource and Chef won't try to enforce anything.

ctl_dir /root/.libnet-openssh-perl/ is not secure at /usr/local/share/perl/5.18.2/Net/OpenSSH/Compat/Perl.pm line 123

I installed Net::OpenSSH::Compat::Perl recently. All the dependencies were installed without any errors. But when I try to login using the following code
$linux_ses= Net::OpenSSH::Compat::Perl->new($host);
$linux_ses->login($linux_uname,$linux_pass);
I get the following error message:
"ctl_dir /root/.libnet-openssh-perl/ is not secure at /usr/local/share/perl/5.18.2/Net/OpenSSH/Compat/Perl.pm line 123."
I am running the script as root and the file permission of /root/.libnet-openssh-perl/ is 700.
The permissions on /root/ could be too loose. Group writeable could mean able to delete a .libnet-openssh-perl/ by someone other than root, which is not a secure situation.
Please check.

How can I specify a custom MySQL socket location for installing DBD::mysql?

I am trying to install DBD::mysql, but the installation fails with the following message:
--------------------
t/00base.............................ok
t/10connect..........................FAILED--Further testing stopped: ERROR: Access
denied for user 'root'#'localhost' (using password: NO)
make: *** [test_dynamic] Error 9
/usr/bin/make test -- NOT OK
---------------------
The problem is, our MySQL installation does not use the default location for the socket and will not be able to connect with the default socket. It's located somewhere else, say, at /dspmydata/data/ourdb/mysql.sock.
Now, how can I tell the DBD::mysql installer that it should use this socket instead of the default one?
Use the option mysql_socket
Example :
my $dbcon = DBI->connect('dbi:mysql:database=DBNAME;mysql_socket=/mysql/tmp/mysql.sock', 'username','password');
Or you can also symlink it:
ln -s /mysql/tmp/mysql.sock /var/lib/mysql/mysql.sock
You're getting that error because your MySQL installation has been configured to require a password for the root user, not because of the location of the socket file*.
If you don't specify a user when you run the install, the name of the currently logged-in user is used. You can specify configuration details like username and password via environment variables or command line options, but for security reasons, I wouldn't recommend doing this for the root user.
Instead, create a test database and test user for the installation. Grant all privileges to the test user (only for the test database, of course). With the MySQL client:
GRANT ALL PRIVILEGES ON test.* TO 'test'#'localhost' IDENTIFIED BY 's3kr1t';
(assuming the database name is test, the user name is test, and the password is s3kr1t)
Export the appropriate environment variables so that Perl can connect to the database you created, e.g.
export DBD_MYSQL_TESTDB=test
export DBD_MYSQL_TESTHOST=localhost
export DBD_MYSQL_TESTPASSWORD=s3kr1+
export DBD_MYSQL_TESTPORT=3306
export DBD_MYSQL_TESTUSER=test
and then start the installation.
* If Perl were unable to find the socket file, you would get an error more like this:
ERROR: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 2002 Can't continue test

Zend_Search_Lucen - [function.fopen]: failed to open stream: Permission denied

I´m trying to follow the Zend Lucene Search Tutorial from Ganesh H S and it´s giving me an error.
Message: fopen(/home/zerego/application/lucene-data/read.lock.file) [function.fopen]: failed to open stream: Permission denied
And if i click in "function.fopen" it show me an other message:
Exception
Message: Resource 'function.fopen' not found
Stack trace:
#0 /home/zerego/library/Zend/Acl.php(774): Zend_Acl->get('function.fopen')
#1 /home/zerego/application/plugins/AccessCheck.php(26): Zend_Acl->isAllowed('admin', 'function.fopen', 'index')
My folder is with 755 permissions and i have tried with 777 but i thing the problem is with my ACL.
I need to give some kind of permissions in my ACL ? or i need to give those kind of permissions in de .htaccess ?
I think you "click" on the Link shown on your Browser when the error appears or? Your Application trys to open an action "function.fopen" wich is not configured in your acl. But thats not important, the link will send you to php documentation and has nothing to do with your application.
The Error is an permission problem, talk to your webhost if you or the "server" is allowed to write/read from the provided directory (group/user).
I had this problem.
What worked in my case is that, aside from chmod 777, is that I changed the owner of the files to the web server user.
In my case my web server runs as daemon. Make sure that the web server user is set as the owner of the index directory and the index files within the directory.
You can use the chown command to change the owner of the files and the folder.
you might have to do 'sudo chown daemon'. I had to on my mac because the daemon user isn't an actual user on the mac system.