openssh-portable | complete implementation of the SSH protocol | Cryptography library
kandi X-RAY | openssh-portable Summary
kandi X-RAY | openssh-portable Summary
OpenSSH is a complete implementation of the SSH protocol (version 2) for secure remote login, command execution and file transfer. It includes a client ssh and server sshd, file transfer utilities scp and sftp as well as tools for key generation (ssh-keygen), run-time key storage (ssh-agent) and a number of supporting programs. This is a port of OpenBSD's OpenSSH to most Unix-like operating systems, including Linux, OS X and Cygwin. Portable OpenSSH polyfills OpenBSD APIs that are not available elsewhere, adds sshd sandboxing for more operating systems and includes support for OS-native authentication and auditing (e.g. using PAM).
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of openssh-portable
openssh-portable Key Features
openssh-portable Examples and Code Snippets
Community Discussions
Trending Discussions on openssh-portable
QUESTION
I was trying to implement GLOB_ALTDIRFUNC
last night, and tripped into an interesting question.
While maybe slightly semantically different, are (void *)
and (struct *)
types equivalent?
Example code:
...ANSWER
Answered 2019-Jul-31 at 12:38From the C99 standard, 6.7.5.1 Pointer declarators:
For two pointer types to be compatible, both shall be identically qualified and both shall be pointers to compatible types.
So void *
and DIR *
aren't compatible.
From 6.7.5.3 Function declarators (including prototypes):
For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists, if both are present, shall agree in the number of parameters and in use of the ellipsis terminator; corresponding parameters shall have compatible types.
So struct dirent *(*)(void *)
(the type of gl_readdir
) nd struct dirent *(*)(DIR *)
(the type of readdir
) aren't compatible.
From 6.3.2.3 Pointers:
A pointer to a function of one type may be converted to a pointer to a function of another type and back again; the result shall compare equal to the original pointer. If a converted pointer is used to call a function whose type is not compatible with the pointed-to type, the behavior is undefined.
So
QUESTION
In *nix, I can create an empty file using cp:
...ANSWER
Answered 2018-Nov-29 at 12:24As @willh99 commented, creating an empty file locally, and then performing scp is the most feasible solution.
So far I came up with this:
QUESTION
I'm trying to set the OOM killer score adjustment for a process, inspired by oom_adjust_setup
in OpenSSH's port_linux.c
. To do that, I open /proc/self/oom_score_adj
, read the old value, and write a new value. Obviously, my process needs to be root or have the capability CAP_SYS_RESOURCE
to do that.
I'm getting a result that I can't explain. When my process doesn't have the capability, I'm able to open that file and read and write values, though the value I write doesn't take effect (fair enough):
...ANSWER
Answered 2018-Jun-20 at 17:05This one was very interesting to crack, took me a while.
The first real hint was this answer to a different question: https://unix.stackexchange.com/questions/364568/how-to-read-the-proc-pid-fd-directory-of-a-process-which-has-a-linux-capabil - just wanted to give the credit.
The reason it does not work as isThe real reason you get "permission denied" there is files under /proc/self/
are owned by root if the process has any capabilities - it's not about CAP_SYS_RESOURCE
or about oom_*
files specifically. You can verify this by calling stat
and using different capabilities. Quoting man 5 proc
:
/proc/[pid]
There is a numerical subdirectory for each running process; the subdirectory is named by the process ID.
Each /proc/[pid] subdirectory contains the pseudo-files and directories described below. These files are normally owned by the effective user and effective group ID of the process. However, as a security measure, the ownership is made root:root if the process's "dumpable" attribute is set to a value other than 1. This attribute may change for the following reasons:
The attribute was explicitly set via the prctl(2) PR_SET_DUMPABLE operation.
The attribute was reset to the value in the file /proc/sys/fs/suid_dumpable (described below), for the reasons described in prctl(2).
Resetting the "dumpable" attribute to 1 reverts the ownership of the /proc/[pid]/* files to the process's real UID and real GID.
This already hints to the solution, but first let's dig a little deeper and see that man prctl
:
PR_SET_DUMPABLE (since Linux 2.3.20)
Set the state of the "dumpable" flag, which determines whether core dumps are produced for the calling process upon delivery of a signal whose default behavior is to produce a core dump.
In kernels up to and including 2.6.12, arg2 must be either 0 (SUID_DUMP_DISABLE, process is not dumpable) or 1 (SUID_DUMP_USER, process is dumpable). Between kernels 2.6.13 and 2.6.17, the value 2 was also permitted, which caused any binary which normally would not be dumped to be dumped readable by root only; for security reasons, this feature has been removed. (See also the description of /proc/sys/fs/suid_dumpable in proc(5).)
Normally, this flag is set to 1. However, it is reset to the current value contained in the file /proc/sys/fs/suid_dumpable (which by default has the value 0), in the following circumstances:
The process's effective user or group ID is changed.
The process's filesystem user or group ID is changed (see credentials(7)).
The process executes (execve(2)) a set-user-ID or set-group-ID program, resulting in a change of either the effective user ID or the effective group ID.
The process executes (execve(2)) a program that has file capabilities (see capabilities(7)), but only if the permitted capabilities gained exceed those already permitted for the process.
Processes that are not dumpable can not be attached via ptrace(2) PTRACE_ATTACH; see ptrace(2) for further details.
If a process is not dumpable, the ownership of files in the process's /proc/[pid] directory is affected as described in proc(5).
Now it's clear: our process has a capability that the shell used to launch it did not have, thus the dumpable attribute was set to false, thus files under /proc/self/
are owned by root rather than the current user.
The fix is as simple as re-setting that dumpable attribute before trying to open the file. Stick the following or something similar before opening the file:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install openssh-portable
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page