| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Fix changing savedir directory mode
|
|/
|
|
|
|
|
|
|
|
| |
Commit 9f5764dac39b ("saveconfig: set right perms on /etc/target/ dir")
fixed CVE-2020-13867 by ensuring that the mode of the target
meta-data directory (/etc/target) was always mode 0600. But users
can specify a different directory, such as "/tmp", and we don't
want targetcli changing the mode of such directories to 0600. So
only change the mode of the directory, when saving a config file,
if the directory is /etc/target.
|
|\
| |
| | |
targetcli: avoild Ctrl+C print error stack
|
| |
| |
| |
| | |
Signed-off-by: Mingzhe Zou <zoumingzhe@qq.com>
|
|\ \
| |/
|/| |
fix setting preference rollback error
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Setting preference maybe rollback when execute multiple targetcli requests concurrently.
ConfigShell always initialization new Console object.
However, the lockfile need to be opened before requesting flock.
At this time, an exception may occur and need to be output to the console.
Currently, ConfigShell always initializes a new Console object.
So, ConfigShell is initialized first to be able to print information.
The prefs.bin file will be loaded when ConfigShell is initialized.
In this case, the old value may be read, if a new preference is being set and not saved.
In order to solve this problem we must first initialize a Console object.
This patch needs https://github.com/open-iscsi/configshell-fb/pull/62 to be merged first.
Signed-off-by: Zou Mingzhe <mingzhe.zou@easystack.cn>
|
|
|
|
| |
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
|\
| |
| | |
fileio backstore: fix sparse file creation
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
fallocate() can't be used to create sparse files because it
actually preallocates all the disk space that will be used by the file
backstore, sparse files do not have preallocated disk space
by definition.
We must therefore use ftruncate().
We can, on the other hand, use fallocate() to create non-sparse
files and fall back to the slower "while() fwrite()" if we
are running on Python version < 3.3 where fallocate() is not available
Fixes 3bd4d8ef7c9b154c53e8b8dd863a570bce7f5c2c
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
|\
| |
| | |
Do not install systemd files in setup.py
|
| |
| |
| |
| |
| | |
setuptools should not perform OS-specific actions such as installing systemd units.
OS-specific actions should be handled by the package manager.
|
|/
|
|
| |
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
|\
| |
| | |
Ensure we have right perms on saveconfig
|
| |
| |
| |
| | |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
| |
| |
| | |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
| |
| |
| | |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\ \
| |/
|/| |
uds: set right permissions at bind() time
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
| |
We fixed it earlier with commit 6e4f39357a90a914d11bac21cc2d2b52c07c213d
but that fixes the issue when someone run the targetclid with systemd
only.
If we don't use targetclid.socket and want to run `targetclid` from
command line, then socket.bind() will create the file with default
permissions.
Hence its good if we can guard the permissions right at the time of .bind()
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|\
| |
| | |
daemonized-mode: add interactive shell support
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Typing somthing and then hitting backspace multiple-times would clear
the prompt previously.
This patch do not let backspace clear the prompt msg.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
$ targetcli
targetcli shell version 2.1.51
Entering targetcli interactive mode for daemonized approach.
Type 'exit' to quit.
/> pwd
/
/> cd /iscsi
/iscsi> ls
o- iscsi .......................................... [Targets: 0]
/iscsi> exit
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
set interactive mode as default to make it appear similar to cli approach,
$ targetcli
targetcli shell version 2.1.51
Entering targetcli interactive mode for daemonized approach.
Type 'exit' to quit.
/> pwd
/
/> cd /iscsi
/> pwd
/iscsi
/> exit
Here we introduce a new global option daemon_use_batch_mode for switching between
batch and interactive modes.
$ targetcli set global daemon_use_batch_mode=true
Parameter daemon_use_batch_mode is now 'true'.
$ targetcli
targetcli shell version 2.1.51
Entering targetcli batch mode for daemonized approach.
Enter multiple commands separated by newline and type 'exit' to run them
all in one go.
/> pwd
/> cd /iscsi
/> pwd
/
/iscsi
Fixes: #160
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\
| |
| | |
Use temp file objects for temporary storage area
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
happen to see yet another issue after we switch to stringIO/bytesIO:
$ targetcli ls
'unicode' does not have the buffer interface
After which I felt like dealing with StringIO/BytesIO is like a
wild goose chase and we are after all attempting to deal with python
incompatible apis.
Technically speaking, the rtslib and configshell libraries are expecting a
string IO stream, but then for python2 with ByteIO() we are passing a
bytestream, and stringIO() is behaving a bit different in python2 than
expected as explained in my previous patch.
Lets simply switch to temporary file in the most secure manner possible,
opening files in string mode will assure the compatibility across the platforms.
At the end we wish to have a consistent behaviour across all python versions.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\
| |
| | |
Fix StringIO/BytesIO stuck issue
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We all know the way python3 handles strings is a bit different.
$ python2
Python 2.7.16 (default, Apr 30 2019, 15:54:43)
[GCC 9.0.1 20190312 (Red Hat 9.0.1-0.10)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> s=io.BytesIO()
>>> s.write('hello')
5L
>>> s.getvalue()
'hello'
>>> s=io.StringIO()
>>> s.write('hello')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unicode argument expected, got 'str'
>>> s.write(u'hello')
5L
>>> s.getvalue()
u'hello'
>>>
$ python3
Python 3.6.8 (default, Dec 5 2019, 15:45:45)
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
>>> s=io.BytesIO()
>>> s.write('hello')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
>>> s.write(b'hello')
5
>>> s.getvalue()
b'hello'
>>> s=io.StringIO()
>>> s.write('hello')
5
>>> s.getvalue()
'hello'
>>>
The way Python2 and Python3 handles String and Bytes IO is different.
* In Python2 BytesIO() accepts text format syntax, and StringIO() expects unicodes
* While in Python3 StringIO() accepts text format syntax, and BytesIO() expects bytes like objects
I think the compatibility of using both the IO streams with python2 and python3 is compromised.
Hence this patch, uses BytesIO() and StringIO() based on python version.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\
| |
| | |
targetclid.sock: change SocketMode to 0600
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
SocketMode=
If listening on a file system socket or FIFO, this option specifies the
file system access mode used when creating the file node. Takes an
access mode in octal notation. Defaults to 0666.
Thanks Alex Murray[@alexmurray], for reporting.
Fixes: #162
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\ \
| |/
|/| |
Fix targetclid daemon infinite stuck
|
|/
|
|
|
|
|
| |
We need to open a byte IO stream because we are actually dealing with
binary data in memory.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\
| |
| | |
Use StringIO as a buffer instead of a file
|
| | |
|
|\ \
| |/
|/| |
setup.py: add the socket and service files to the data_files section
|
|/
|
|
| |
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
|
| |
|
|\
| |
| | |
targetcli: depreciate the redundant '--tcp' option
|
| |
| |
| |
| |
| |
| |
| |
| | |
It looks like '--tcp' option is no more needed after our recent
global auto_use_daemon flag addition, which helps set/unset the
daemonized approach.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\ \
| |/
|/| |
Remove Epydoc markup from command messages
|
| |
| |
| |
| | |
Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
|
|\ \
| | |
| | | |
Improve user experience with daemonized appoach
|
| | |
| | |
| | |
| | | |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| | |
| | |
| | |
| | | |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| | |
| | |
| | |
| | | |
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Problem:
-------
Noticing inconsistency with prefs when switching between cli mode and
daemon mode
Solution:
-------
Makesure to read/load the prefs on every new connection
Thanks to 'Xiubo Li <xiubli@redhat.com>' for reporting the problem
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Problem:
-------
When auto_use_daemon=true, entering multi-line command-mode/shell-mode appears
like the cli is stuck for new users, as we do not display any info now :-)
$ targetcli
---- nothing here, is it stuck ? -------
$ targetcli
cd /backstores/
get global auto_use_daemon
pwd
ls
exit
auto_use_daemon=true
/backstores
o- backstores ................................................ [...]
o- block .................................... [Storage Objects: 0]
o- fileio ................................... [Storage Objects: 0]
o- pscsi .................................... [Storage Objects: 0]
o- ramdisk .................................. [Storage Objects: 0]
o- user:glfs ................................ [Storage Objects: 0]
Solution:
-------
Add some userful info and a '/> ' in each line,
$ targetcli
targetcli shell version 2.1.50
Entering targetcli batch mode for daemonized approach.
Enter multiple commands separated by newline and type 'exit' to run them all in one go.
/> cd /backstores/
/> get global auto_use_daemon
/> pwd
/> ls
/> exit
auto_use_daemon=true
/backstores
o- backstores ................................................ [...]
o- block .................................... [Storage Objects: 0]
o- fileio ................................... [Storage Objects: 0]
o- pscsi .................................... [Storage Objects: 0]
o- ramdisk .................................. [Storage Objects: 0]
o- user:glfs ................................ [Storage Objects: 0]
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Problem:
-------
Currently when auto_use_daemon is set to true and in case for some
reasons user do not want to start the daemon or the dameon is not starting
succefully for some unknown reason, then there is no way to bypass the
calls to dameon and use cli directly
$ targetcli pwd
[Errno 111] Connection refused
Solution:
--------
Provide an option with cli to turn auto_use_daemon to false.
$ targetcli pwd
[Errno 111] Connection refused
Currently auto_use_daemon is true, hence please make sure targetclid daemon is running ...
(or)
Incase if you wish to turn auto_use_daemon to false then run '#targetcli --disable-daemon'
$ targetcli --help
Usage: ./scripts/targetcli [--version|--help|CMD|--tcp|--disable-daemon]
[...]
--disable-daemon Turn-off the global auto use daemon flag
See man page for more information.
$ targetcli --disable-daemon
Parameter auto_use_daemon is now 'false'.
$ targetcli pwd
/
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When auto_use_daemon is set to true and daemon is not running/stopped
Before:
------
$ targetcli ls
[Errno 111] Connection refused
Now:
---
$ targetcli ls
[Errno 111] Connection refused
Currently auto_use_daemon is true, hence please make sure targetclid daemon is running ...
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
|\ \
| | |
| | | |
Fix daemon and python 3.7 issues v2
|
| | |
| | |
| | |
| | |
| | |
| | | |
Before, we would get a "Bad File Descriptor" message when
a signal causes closure of the socket while waiting on a
socket message.
|