Pages

Friday, August 30, 2019

Fedora 30 : DNF history.

This option of the tool DNF can help you to see and rollback by transaction history. NOTE: This option not work if you use the system-upgrade to another version of the distro.
[root@desk mythcat]# dnf
usage: dnf [options] COMMAND

List of Main Commands:

...
history                   display, or use, the transaction history
... 
This command displays DNF transaction history starting from the latest transaction on top of the listing.
[root@desk mythcat]# dnf history 
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    64 | groupupdate Minimal Inst | 2019-08-29 21:59 | Install        |    2   
    63 | groupupdate Minimal Inst | 2019-08-29 21:59 | Install        |    2   
To display information about this transaction use this command:
[root@desk mythcat]# dnf history info 64
Transaction ID : 64
Begin time     : Thu 29 Aug 2019 09:59:52 PM EEST
Begin rpmdb    : 1643:6a997d9fa53488ec0003727cb0394b18b6b4deaf
End time       : Thu 29 Aug 2019 09:59:53 PM EEST (1 seconds)
End rpmdb      : 1643:6a997d9fa53488ec0003727cb0394b18b6b4deaf
User           : Catalin George Festila 
Return-Code    : Success
Releasever     : 30
Command Line   : groupupdate Minimal Install
Packages Altered:
    Install @core                
    Install @minimal-environment 
To rollback the latest transaction use this:
[root@desk mythcat]# dnf history undo 64

Thursday, August 22, 2019

Fedora 30 : Set up the Linux Malware Detect.

If you have an SELinux warning detection then the details you can see how can be fixed:
[mythcat@desk ~]$ su
Password: 
[root@desk mythcat]# ausearch -c 'systemd' --raw | audit2allow -M my-systemd
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i my-systemd.pp

[root@desk mythcat]# semodule -X 300 -i my-systemd.pp
This tool comes with three modes that the monitor can be executed with and they relate to what will be monitored.
These modes are USERS|PATHS|FILES.
The options break down as follows:
  • USERS: The users option will take the homedirs of all system users that are above inotify_minuid and monitor them.If inotify_webdir is set then the users webdir, if it exists, will only be monitored;
  • PATHS: A comma spaced list of paths to monitor;
  • FILE: A line spaced file list of paths to monitor
$ maldet --monitor users
$ maldet --monitor /root/initial-setup-ks.cfg
$ maldet --monitor /home/mythcat
Let's test the USERS option:
[mythcat@desk maldetect-1.6.4]$ maldet --monitor users
Linux Malware Detect v1.6.4
            (C) 2002-2019, R-fx Networks 
            (C) 2019, Ryan MacDonald 
This program may be freely redistributed under the terms of the GNU GPL v2

maldet(7958): {mon} could not find inotifywait command, install yum package inotify-tools or 
download from https://github.com/rvoicilas/inotify-tools/wiki/


[root@desk maldetect-1.6.4]# dnf search inotify-tools
Last metadata expiration check: 0:01:39 ago on Wed 21 Aug 2019 11:09:22 PM EEST.
============================================ Name Exactly Matched: inotify-tools ======
inotify-tools.i686 : Command line utilities for inotify
inotify-tools.x86_64 : Command line utilities for inotify
================================================ Name Matched: inotify-tools ======
inotify-tools-devel.i686 : Headers and libraries for building apps that use libinotifytools
inotify-tools-devel.x86_64 : Headers and libraries for building apps that use libinotifytools
[root@desk maldetect-1.6.4]# dnf install inotify-tools.x86_64
...
Installed:
  inotify-tools-3.14-16.fc30.x86_64                                                                                          

Complete!
[root@desk maldetect-1.6.4]# maldet --monitor users
Linux Malware Detect v1.6.4
            (C) 2002-2019, R-fx Networks 
            (C) 2019, Ryan MacDonald 
This program may be freely redistributed under the terms of the GNU GPL v2

maldet(973): {mon} set inotify max_user_watches to 16384
maldet(973): {mon} added /dev/shm to inotify monitoring array
maldet(973): {mon} added /var/tmp to inotify monitoring array
maldet(973): {mon} added /tmp to inotify monitoring array
maldet(973): {mon} starting inotify process on 3 paths, this might take awhile...
maldet(973): {mon} inotify startup successful (pid: 1800)
maldet(973): {mon} inotify monitoring log: /usr/local/maldetect/logs/inotify_log

Wednesday, August 21, 2019

Fedora 30 : Testing the Linux Malware Detect.

Linux Malware Detect (LMD) is a malware scanner for Linux released under the GNU GPLv2 license, that is designed around the threats faced in shared hosted environments.
This tool is provided by R-fx Networks.
Let's install and test it:
[mythcat@desk ~]$ wget http://www.rfxn.com/downloads/maldetect-current.tar.gz
[mythcat@desk ~]$ tar -xf maldetect-current.tar.gz 
[mythcat@desk ~]$ cd maldetect-1.6.4/
[mythcat@desk maldetect-1.6.4]$ su
Password: 
[root@desk maldetect-1.6.4]# ./install.sh
Failed to enable unit: Unit file maldet.service does not exist.
Linux Malware Detect v1.6.4
            (C) 2002-2019, R-fx Networks <proj@r-fx.org>
            (C) 2019, Ryan MacDonald <ryan@r-fx.org>
This program may be freely redistributed under the terms of the GNU GPL

installation completed to /usr/local/maldetect
config file: /usr/local/maldetect/conf.maldet
exec file: /usr/local/maldetect/maldet
exec link: /usr/local/sbin/maldet
exec link: /usr/local/sbin/lmd
cron.daily: /etc/cron.daily/maldet
maldet(31046): {sigup} performing signature update check...
maldet(31046): {sigup} local signature set is version 201907043616
maldet(31046): {sigup} new signature set 2019081912001 available
maldet(31046): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-sigpack.tgz
maldet(31046): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-cleanv2.tgz
maldet(31046): {sigup} verified md5sum of maldet-sigpack.tgz
maldet(31046): {sigup} unpacked and installed maldet-sigpack.tgz
maldet(31046): {sigup} verified md5sum of maldet-clean.tgz
maldet(31046): {sigup} unpacked and installed maldet-clean.tgz
maldet(31046): {sigup} signature set update completed
maldet(31046): {sigup} 15552 signatures (12740 MD5 | 2035 HEX | 777 YARA | 0 USER)
[root@desk maldetect-1.6.4]# vim /usr/local/maldetect/conf.maldet
Change this row to scan_user_access=1
Now you can run it:
[mythcat@desk ~]$ /usr/local/sbin/maldet -a 
Linux Malware Detect v1.6.4
            (C) 2002-2019, R-fx Networks 
            (C) 2019, Ryan MacDonald 
This program may be freely redistributed under the terms of the GNU GPL v2

maldet(32628): {scan} signatures loaded: 15552 (12740 MD5 | 2035 HEX | 777 YARA | 0 USER)
maldet(32628): {scan} building file list for , this might take awhile...
maldet(32628): {scan} setting nice scheduler priorities for all operations: cpunice 19 , ionice 6
maldet(32628): {scan} file list completed in 13s, found 44109 files...
maldet(32628): {scan} scan of  (44109 files) in progress...

Tuesday, August 20, 2019

Fedora 30 : Install the last version of PHP.

I try to install the last version of PHP version 7.4.0beta2 with Fedora 30 distro the LXQt environment.
I have not used this programming language for a few years and it is a good issue to remember it.
I download teh archive from the official website and I run these commands:
[mythcat@desk ~]$ cd php/
[mythcat@desk php]$ tar -xf php-7.4.0beta2.tar.xz 
[mythcat@desk php]$ cd php-7.4.0beta2/
[mythcat@desk php-7.4.0beta2]$ ./configure --prefix=$HOME/local
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... no
checking for gcc... no
configure: error: in `/home/mythcat/php/php-7.4.0beta2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[mythcat@desk php-7.4.0beta2]$ vi config
[mythcat@desk php-7.4.0beta2]$ vi config
config.log    config.nice   configure     configure.ac  
[mythcat@desk php-7.4.0beta2]$ vi config.log 
Let's try to install all requests for compiler:
[root@desk home]# dnf groupinstall "Development Tools"
Let's see if these settings working well:
[root@desk home]# dnf groupinstall "Development Tools"
Waiting for process with pid 4373 to finish.
[root@desk home]# kill  -9 4373
[root@desk home]# dnf groupinstall "Development Tools"
...
Complete!
[root@desk home]# dnf install libxml2-devel.x86_64
...
Installed:
  libxml2-devel-2.9.9-2.fc30.x86_64                          xz-devel-5.2.4-5.fc30.x86_64
The last dnf command come with this output:
checking for sqlite3 > 3.7.4... no
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:

Package 'sqlite3', required by 'virtual:world', not found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix. 
Let's test it with an old version of sqlite:
[root@desk home]# dnf install sqlite-devel.x86_64 
...
Installed:
  sqlite-devel-3.26.0-6.fc30.x86_64 
And is working well:
[mythcat@desk php-7.4.0beta2]$ ./configure --prefix=$HOME/local
...
config.status: executing default commands

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[mythcat@desk php-7.4.0beta2]$ make 
... 

Build complete.
Don't forget to run 'make test'.
[mythcat@desk php-7.4.0beta2]$ make install
...
[mythcat@desk php-7.4.0beta2]$ make test
...
FAILED TEST SUMMARY
---------------------------------------------------------------------
php://fd wrapper: invalid file descriptor [ext/standard/tests/file/php_fd_wrapper_04.phpt]
=====================================================================

You may have found a problem in PHP.
This report can be automatically sent to the PHP QA team at
http://qa.php.net/reports and http://news.php.net/php.qa.reports
This gives us a better understanding of PHP's behavior.
If you don't want to send the report immediately you can choose
option "s" to save it.  You can then email it to qa-reports@lists.php.net later.
Do you want to send this report now? [Yns]: s
sh: autoconf: command not found
Please send /home/mythcat/php/php-7.4.0beta2/php_test_results_20190819_2038.txt to qa-reports@lists.php.net 
manually, thank you.
make: *** [Makefile:201: test] Error 1
[mythcat@desk php-7.4.0beta2]$ export PATH=$HOME/local/bin:$PATH
[mythcat@desk php-7.4.0beta2]$ . ~/.bash_profile
[mythcat@desk php-7.4.0beta2]$ which php
~/local/bin/php
[mythcat@desk php-7.4.0beta2]$ php -v
PHP 7.4.0beta2 (cli) (built: Aug 19 2019 23:31:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies
Let's test it:
[mythcat@desk php-7.4.0beta2]$ php -i | grep 'API'
Server API => Command Line Interface
PHP API => 20190529
Zend Extension Build => API320190529,NTS
PHP Extension Build => API20190529,NTS
DOM/XML API Version => 20031129
Phar API version => 1.1.1
[mythcat@desk php-7.4.0beta2]$ echo '' > infophp.php
[mythcat@desk php-7.4.0beta2]$ php -f infophp.php 
phpinfo()
PHP Version => 7.4.0beta2

System => Linux desk 5.2.8-200.fc30.x86_64 #1 SMP Sat Aug 10 13:21:39 UTC 2019 x86_64
Build Date => Aug 19 2019 23:26:58
Configure Command =>  './configure'  '--prefix=/home/mythcat/local'
Server API => Command Line Interface
Virtual Directory Support => disabled
...
Use interactive mode and hit Ctr+D keys to run it:
[mythcat@desk php-7.4.0beta2]$ php -a
Interactive mode enabled


hello, world1636562552
I can see the compiled modules:
[mythcat@desk php-7.4.0beta2]$ php -m 
[PHP Modules]
Core
ctype
date
dom
fileinfo
filter
hash
iconv
json
libxml
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter

[Zend Modules]

Friday, August 16, 2019

Fedora 30 : First steps with Fedora and GitHub.

In this tutorial I will show you how you can use Fedora and your GitHub account for your projects.
Let's solve this issue in a simple way.
First, you need to install the git tool with dnf tool:
[root@desk mythcat]# dnf -y install git
Let's see the version of this tool with a regular user:
[mythcat@desk ~]$ git --version
git version 2.21.0
Let's set up the user for my GitHub account:
[mythcat@desk ~]$ git config --global user.name "catafest"
[mythcat@desk ~]$ git config --global user.email "catafest@yahoo.com"
You can see it later with this command:
[mythcat@desk ~]$ git config --list
[mythcat@desk ~]$ git config --global --list
I used this commands to create a folder for my git projects:
[mythcat@desk ~]$ mkdir project_github
[mythcat@desk ~]$ cd project_github/ 
Now I can download my GitHub project named flask_yt from here:
[mythcat@desk project_github]$ git clone https://github.com/catafest/flask_yt.git
Cloning into 'flask_yt'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 23 (delta 1), reused 14 (delta 0), pack-reused 0
Unpacking objects: 100% (23/23), done.
If you don't have one then you can create your new project on your GitHub account. Let's make some changes into README.md file:
[mythcat@desk project_github]$ cd flask_yt/
[mythcat@desk flask_yt]$ vim README.md 
...
Now I can use git tool:
[mythcat@desk flask_yt]$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

        modified:   README.md

no changes added to commit (use "git add" and/or "git commit -a")
[mythcat@desk flask_yt]$ git add *
[mythcat@desk flask_yt]$ git commit -m "first commit"
[master 56f1e53] first commit
 1 file changed, 1 insertion(+)
Now I can use my username and password from GitHub when I run this command:
[mythcat@desk flask_yt]$ git push origin master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 2 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 352 bytes | 352.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/catafest/flask_yt.git
   5ecffdd..56f1e53  master -> master 
The changes from README.md will be send to my GitHub website.

Wednesday, August 14, 2019

Fedora 30 : First steps with Fedora firewall.

In computing, a firewall is a network security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules.[1] A firewall typically establishes a barrier between a trusted internal network and untrusted external network, such as the Internet.[2], see the wikipedia. In this short tutorial about the Fedora firewall subject, I will show you how you can use firewall commands to set it. The install is simple with dnf tool:
[root@desk mythcat]# dnf install firewalld firewall-config 
Let's start with the status of your firewall:
[root@desk mythcat]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
...
You can use start , restart or stop it.

[root@desk mythcat]# systemctl start firewalld
[root@desk mythcat]# systemctl restart firewalld
[root@desk mythcat]# systemctl stop firewalld
Let's see active zones:
[root@desk mythcat]# firewall-cmd --get-active-zones
We can see all active for public zone with:
[root@desk mythcat]# firewall-cmd --zone=public --list-all
We can see all ports for public zone:
[root@desk mythcat]# firewall-cmd --zone=public --list-ports 
These commands are used for add and remove ports:
[root@desk mythcat]# firewall-cmd --permanent --zone=public --add-port=80/tcp
[root@desk mythcat]# firewall-cmd --permanent --zone=public --remove-port=80/tcp
Let's see services:
[root@desk mythcat]# firewall-cmd --get-services 
RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client 
bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine cockpit 
condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns docker-registry docker-swarm 
dropbox-lansync elasticsearch etcd-client etcd-server finger freeipa-ldap freeipa-ldaps 
freeipa-replication freeipa-trust ftp ganglia-client ganglia-master git gre high-availability 
http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kerberos 
kibana klogin kpasswd kprop kshell ldap ldaps libvirt libvirt-tls lightning-network llmnr 
managesieve matrix mdns minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql 
nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole 
plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio
 puppetmaster quassel radius redis rpc-bind rsh rsyncd rtsp salt-master samba samba-client 
samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid 
ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tftp 
tftp-client tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http 
wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent 
zabbix-server
Let's add and remove one service named ftp:
[root@desk mythcat]# firewall-cmd --zone=public --add-service=ftp
[root@desk mythcat]# firewall-cmd --zone=public --remove-service=ftp
Let's see all running services:
[root@desk mythcat]# firewall-cmd --zone=public --list-services
If you want to block/unblock any incoming or outgoing connections then use this:
[root@desk mythcat]# firewall-cmd --panic-on
[root@desk mythcat]# firewall-cmd --panic-off 
For example, after you use panic-on then you can check with this:
[root@desk mythcat]# ping google.com -c 1
[root@desk mythcat]# firewall-cmd --query-panic
[root@desk mythcat]# firewall-cmd --panic-off
You can masquerade your IP address with:
[root@desk mythcat]# firewall-cmd --zone=external --query-masquerade
Another example: we can forward all tcp port 80 connections to IP 6.6.6.6 :
[root@desk mythcat]# firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toaddr=6.6.6.6
Let's see ICMP:
[root@desk mythcat]# firewall-cmd --get-icmptypes
address-unreachable bad-header beyond-scope communication-prohibited destination-unreachable 
echo-reply echo-request failed-policy fragmentation-needed host-precedence-violation 
host-prohibited host-redirect host-unknown host-unreachable ip-header-bad 
neighbour-advertisement neighbour-solicitation network-prohibited network-redirect 
network-unknown network-unreachable no-route packet-too-big parameter-problem 
port-unreachable precedence-cutoff protocol-unreachable redirect reject-route 
required-option-missing router-advertisement router-solicitation source-quench 
source-route-failed time-exceeded timestamp-reply timestamp-request tos-host-redirect 
tos-host-unreachable tos-network-redirect tos-network-unreachable 
ttl-zero-during-reassembly ttl-zero-during-transit unknown-header-type 
unknown-option
We can use it for block or not the echo:
[root@desk mythcat]# firewall-cmd --zone=external --query-icmp-block=echo-reply
[root@desk mythcat]# firewall-cmd --zone=external --add-icmp-block=echo-reply
[root@desk mythcat]# firewall-cmd --direct --get-rules ipv4 filter IN_public
[root@desk mythcat]# firewall-cmd --direct --add-rule ipv4 filter IN_public_allow 
...
I cannot show you a magic rule because this depends by your network and your software. You can use this command to see all into a graphic interface.
[root@desk mythcat]# firewall-config
This will give a good image of your firewall settings.

Monday, August 12, 2019

Fedora 30 : First step with Ionic.

My laptop is crash and is hard for me to write tutorials for me.
The last tutorial I created with Fedora 30 is about Ionic.
You can read this tutorial here.

Friday, August 9, 2019

Fedora 30 : The VS Code on Fedora.

The Visual Studio Code editor is officially distributed as a Snap package in the Snap Store.
It runs well on the Fedora distro, but with my Window operating system is crash often.
I like to develop my python projects like Flask and Django with this editor.
You can install it very easy on Fedora with the dnf tool:
[mythcat@desk ~]# dnf check-update
[mythcat@desk ~]# dnf update
[mythcat@desk ~]# exit
[mythcat@desk ~]$ sudo dnf install code
[sudo] password for mythcat: 
...
Is this ok [y/N]: y
...
Installed:
  code-1.37.0-1565228125.el7.x86_64
For Snap install you can use this command:
sudo snap install --classic code
Let's run it with:
[mythcat@desk ~]$ code
You can find many videos about this editor at official YouTube channel.
The result of my installation on Fedora 30 distro can be seen at this screenshot:

Tuesday, August 6, 2019

Fedora 30 : The gpg tool.

GnuPG allows you to encrypt and sign your data and communications; it features a versatile key management system, along with access modules for all kinds of public key directories. see the official webpage.
Today I test it with Fedora 30 distro and works well.
You can find this tool in many Linux distros.
Let's install it with dnf tool.
[root@desk mythcat]# dnf install gnupg
Last metadata expiration check: 0:18:30 ago on Tue 06 Aug 2019 11:07:20 AM EEST.
Package gnupg2-2.2.17-1.fc30.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@desk mythcat]# exit
exit
This tool can be run with the gpg command and arguments: Let's see some example:
[mythcat@desk ~]$ gpg --list-secret-keys
[mythcat@desk ~]$ gpg --list-keys
[mythcat@desk ~]$ gpg --full-generate-key
gpg (GnuPG) 2.2.17; Copyright (C) 2019 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: Catalin George Festila
Email address: catafest@yahoo.com
Comment: test gpg key 
You selected this USER-ID:
...
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O

Enter password for protection

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
... 
This command is normally only used interactive to generate a new key pair.
[mythcat@desk ~]$ gpg --gen-key
gpg (GnuPG) 2.2.17; Copyright (C) 2019 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Note: Use "gpg --full-generate-key" for a full featured key generation dialog.

GnuPG needs to construct a user ID to identify your key.

Real name: 
... 
Let's see the list with the keys:
[mythcat@desk ~]$ gpg --list-keys
/home/mythcat/.gnupg/pubring.kbx
--------------------------------
The key can be exported in a binary format with this command:
[mythcat@desk ~]$ gpg --output mythcat --export catafest@yahoo.com
When the key is to be sent through email or published on a web page will can use a command-line option --armor.
[mythcat@desk ~]$ gpg --armor --export catafest@yahoo.com > catafest.key
Let's see this key:
[mythcat@desk ~]$ cat catafest.key 
...
Now If you can see the new key:
[mythcat@desk ~]$ gpg --list-keys
/home/mythcat/.gnupg/pubring.kbx
-------------------------------- 
I can edit this key:
[mythcat@desk ~]$ gpg --edit-key catafest@yahoo.com
gpg (GnuPG) 2.2.17; Copyright (C) 2019 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Secret key is available.
...
gpg> ?
quit        quit this menu
save        save and quit
help        show this help
fpr         show key fingerprint
grip        show the keygrip
...
enable      enable key
disable     disable key
showphoto   show selected photo IDs
clean       compact unusable user IDs and remove unusable signatures from key
minimize    compact unusable user IDs and remove all signatures from key
...
The key can be import and export it:
[mythcat@desk ~]$ gpg --export -a catafest >  catafest_public.key
[mythcat@desk ~]$ gpg --import -a catafest_public.key 
...
gpg: Total number processed: 1
gpg:              unchanged: 1
Let's see one example with encrypt and decrypt feature:
[mythcat@desk ~]$ echo "test gpg encrypt" >> gpgtest.txt
[mythcat@desk ~]$ gpg -e -r "catafest" gpgtest.txt 
[mythcat@desk ~]$ gpg -d  gpgtest.txt.gpg 
...
test gpg encrypt
Another example is encrypt and decrypt using aditional arguments like --batch and --passphrase-file:
[mythcat@desk ~]$ gpg --export --armor --output catafest.asc catafest@yahoo.com
[mythcat@desk ~]$ gpg --import catafest.asc 
...
gpg: Total number processed: 1
gpg:              unchanged: 1
[mythcat@desk ~]$ echo "this text will be encrypt and decrypt" | gpg --passphrase-file catafest.asc 
--batch --symmetric --cipher-algo AES256 > testgpg_001.txt
[mythcat@desk ~]$ gpg --batch --passphrase-file catafest.asc -d testgpg_001.txt
gpg: AES256 encrypted data
gpg: encrypted with 1 passphrase
this text will be encrypt and decrypt

Monday, July 8, 2019

Fedora 30 : Using the python-wikitcms.

This python module named python-wikitcms can be used for interacting with the Fedora wiki.
The Fedora wiki used Fedora's Wikitcms.
Today I test it and works great with Fedora distro version 30.
First, the install of the fedora package with DNF tool:
[root@desk mythcat]# dnf install python3-wikitcms.noarch
...
Downloading Packages:
(1/8): python3-mwclient-0.9.3-3.fc30.noarch.rpm 186 kB/s |  61 kB     00:00    
(2/8): python3-fedfind-4.2.5-1.fc30.noarch.rpm  314 kB/s | 105 kB     00:00    
(3/8): python3-cached_property-1.5.1-3.fc30.noa  41 kB/s |  20 kB     00:00    
(4/8): python3-requests-oauthlib-1.0.0-1.fc29.n 313 kB/s |  40 kB     00:00    
(5/8): python3-jwt-1.7.1-2.fc30.noarch.rpm      112 kB/s |  42 kB     00:00    
(6/8): python3-oauthlib-2.1.0-1.fc29.noarch.rpm 293 kB/s | 153 kB     00:00    
(7/8): python3-simplejson-3.16.0-2.fc30.x86_64. 641 kB/s | 278 kB     00:00    
(8/8): python3-wikitcms-2.4.2-2.fc30.noarch.rpm 264 kB/s |  84 kB     00:00
I used this simple example to get information about the Fedora wiki:
[mythcat@desk ~]$ python3
Python 3.7.3 (default, May 11 2019, 00:38:04) 
[GCC 9.1.1 20190503 (Red Hat 9.1.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from wikitcms.wiki import Wiki
>>> my_site = Wiki()
>>> event = my_site.current_event
>>> print(event.version)
31 Rawhide 20190704.n.1
>>> page = my_site.get_validation_page('Installation','23','Final','RC10')
>>> for row in page.get_resultrows():
...     print(row.testcase)
... 
QA:Testcase_Mediakit_Checksums
QA:Testcase_Mediakit_ISO_Size
QA:Testcase_Mediakit_Repoclosure
QA:Testcase_Mediakit_FileConflicts
QA:Testcase_Boot_default_install
...
>>> dir(my_site)
I used this source code to login with my account.
>>> my_site.login()
A webpage is open to get access to the account and show this info:
The OpenID Connect client Wiki Test Control Management System is asking to authorize access for mythcat. this allow you to access it 
After I agree with this the page tells me to close it:
You can close this window and return to the CLI
The next examples show you how to get and show information from the wiki:
>>> print(my_site.username)
Mythcat
>>> result = my_site.api('query', titles='Mythcat')
>>> for page in result['query']['pages'].values():
...             print(page['title'])
... 
Mythcat
>>> for my_contributions in my_site.usercontributions('Mythcat'):
...     print(my_contributions)
...
This python module comes with low documentation.

Sunday, June 30, 2019

Fedora 30 : The Pythonic tool.

The tutorial for today is about Pythonic tool.
Named Pythonic is a graphical programming tool that makes it easy for users to create Python applications using ready-made function modules.
This tool providing the consistent features and characteristics of a trading bot with just a few clicks.
The Pythonic tool is currently available in four languages: English, German, Spanish, and Chinese. 
The tool comes with basic functions such as a scheduler, if-branches, connectivity, and logging functions are available out of the box and can be parameterized using a corresponding GUI.
Each graphical element is functionally processed individually.
The base idea is: A unique graphical input mask to carry out the parameterization necessary for processing, then after a process completes successfully, the returned result can be transferred to a subsequent process for further use.
You can use server processes can be placed in parallel in the background as listener applications that wait for external events and initiate the creation of a process when the event arrives.
Pythonic's data type list makes it easy to utilize different access techniques (push, pop, insert, append).
The install of this tool is easy on Fedora 30 distro:
[mythcat@desk ~]$ python3.7 -m pip install Pythonic --user
Collecting Pythonic
...
Successfully installed PyQt5-5.8.2 Pythonic-0.12 pandas-0.24.2 pythonic-binance-0.7.2
This is a screenshot with this tool.

Tuesday, June 4, 2019

Fedora 30 : About HTTPie.

From the official website we can get this info about this tool.
HTTPie consists of a single http command designed for painless debugging and interaction with
  • HTTP servers, RESTful APIs, and web services:
  • Sensible defaults;
  • Expressive and intuitive command syntax;
  • Colorized and formatted terminal output;
  • Built-in JSON support;
  • Persistent sessions;
  • Forms and file uploads;
  • HTTPS, proxies, and authentication support;
  • Support for arbitrary request data and headers;
  • Wget-like downloads;
  • Extensions;
  • Linux, macOS, and Windows support;
  • And more…
Let's install this tool:
[root@desk mythcat]# dnf install httpie
...
Installed:
  httpie-0.9.4-13.fc30.noarch       python3-pygments-2.2.0-16.fc30.noarch 
Let's try a simple example:
[mythcat@desk ~]$ http httpie.org
HTTP/1.1 301 Moved Permanently
CF-RAY: 4e18f3613c36acf4-OTP
Cache-Control: max-age=3600
Connection: keep-alive
Date: Tue, 04 Jun 2019 09:41:22 GMT
Expires: Tue, 04 Jun 2019 10:41:22 GMT
Location: https://httpie.org/
Server: cloudflare
Transfer-Encoding: chunked
Vary: Accept-Encoding
The tool can also be tested online here.

Tuesday, May 28, 2019

Fedora 30 : Commands and tools that handle assembly files - part 002.

Another good approach to this topic is this Fedora tool.
The development team tells us: GNUSim8085 is a graphical simulator, assembler and debugger for the Intel 8085 microprocessor in Linux and Windows.

  • A simple editor component with syntax highlighting.
  • A keypad to input assembly language instructions with appropriate arguments.
  • Easy view of register contents.
  • Easy view of flag contents.
  • Hexadecimal - Decimal converter.
  • View of stack, memory and I/O contents.
  • Support for breakpoints for program debugging.
  • Stepwise program execution.
  • One click conversion of assembly program to opcode listing.
  • Printing support.
  • UI translated in various languages.
Let's install this fedora package:
[root@desk mythcat]# dnf install gnusim8085.x86_64
...
Installed:
  gnusim8085-1.3.7-19.fc30.x86_64         electronics-menu-1.0-21.fc30.noarch   
  gtksourceview2-2.11.2-27.fc29.x86_64   

Complete!
Now you can run it with this command:
[mythcat@desk ~]$ gnusim8085
The GUI interface is simple to understand and easy to use for a developer.
The Intel 8085 has seven internal general-purpose 8-bit registers A, B, C, D, E, H, L, and 5 flags — S (sign), Z (zero), AC (Aux Carry), P (Parity) and CY (Carry).
The processor has a total of 246 instructions with which we can manipulate data in the processor registers and memory.
The assembler Intel 8085 mnemonics with the instruction strings, labels define with a named point in the code, the target for JMP or CALL instructions, comments start line with a semicolon ‘;’ is ignored by the assembler and pseudo codes to the assembler that provides some features to the coding process.
For another development assembly tools for hardware, you can find more info on this wiki page.

Fedora 30 : Application packages with snap tool.

Snaps are application packages for desktop, cloud, and IoT that are easy to install, secure, cross-platform and dependency-free, see here.
The install of this tool with the dnf install tool is simple:
[root@desk snap]# dnf install snap
...
Installed:
  snap-0.6-13.fc29.noarch          python2-crypto-2.6.1-25.fc30.x86_64         
Complete!
Let's make the settings for this tool:
[mythcat@desk snap]$ sudo ln -s /var/lib/snapd/snap /snap
[mythcat@desk snap]$ snap install snapcraft --classic
snapcraft 3.5 from Canonical✓ installed

[mythcat@desk ~]$ snap help
The snap command lets you install, configure, refresh and remove snaps.
Snaps are packages that work across many different Linux distributions,
enabling secure delivery and operation of the latest apps and utilities.

Usage: snap  [...]

Commands can be classified as follows:

         Basics: find, info, install, list, remove
        ...more: refresh, revert, switch, disable, enable
        History: changes, tasks, abort, watch
        Daemons: services, start, stop, restart, logs
       Commands: alias, aliases, unalias, prefer
  Configuration: get, set, wait
        Account: login, logout, whoami
    Permissions: connections, interfaces, interface, connect, disconnect
      Snapshots: saved, save, check-snapshot, restore, forget
          Other: version, warnings, okay, ack, known
    Development: run, pack, try, download, prepare-image

For more information about a command, run 'snap help '.
For a short summary of all commands, run 'snap help --all'.
[mythcat@desk ~]$ snap refresh
All snaps up to date.  
Now we can install an application and run it.
Let's try with the vlc application:
[mythcat@desk ~]$ snap install vlc
vlc 3.0.6 from VideoLAN✓ installed
[mythcat@desk ~]$ snap run  vlc
VLC media player 3.0.6 Vetinari (revision 3.0.6-0-g5803e85)
[00000000019ca3d0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
Qt: Session management error: None of the authentication protocols specified are supported
[0000000001a5fae0] main playlist: playlist is empty
QObject::~QObject: Timers cannot be stopped from another thread
Not all application will run on Fedora 30.
For example, I try with the qalculate application and not work:
[mythcat@desk ~]$ sudo snap install qalculate
[sudo] password for mythcat: 
snap "qalculate" is already installed, see 'snap help refresh'
When I try to run it the error was the qalculate application cannot be found.

Monday, May 6, 2019

Fedora 30 : Kite now works with Linux.

The development team comes with these new features for this Linux tool named Kite:
Code Faster in Python with Line-of-Code Completions Kite integrates with your IDE and uses machine learning to give you useful code completions for Python. Start coding faster today.
This tool integrates with all the top Python IDEs - Atom, Pycharm, Sublime, VS Code and Vim.
The install process is simple:
[mythcat@desk ~]$ bash -c "$(wget -q -O - https://linux.kite.com/dls/linux/current)"

This script will install Kite!

We hope you enjoy! If you run into any issues, please reach out at support@kite.com or feedback@kite.com

- The Kite Team

Press enter to continue...
Downloading kite-installer binary using wget...
Checking to see if all dependencies are installed....

Kite watches your workspace to be notified when python files change on disk. This allows us to
provide the latest information & completions from your coding environment. However, for larger
workspaces, Kite can exceed the default limits on inotify watches, which can result in a degraded experience. 

We can fix this by placing a file in /etc/sysctl.d/ to increase this limit.
Configure inotify now? (you might be asked for your sudo password) [Y/n] Y
Creating /etc/sysctl.d/30-kite.conf...
[sudo] password for mythcat: 
Running ./kite-installer install
[installer] no previous kite installation found
[installer] latest version is 2.20190503.3, downloading now...
[installer] verifying checksum
[installer] validating signature
[installer] installing version 2.20190503.3
[installer] installed ~/.config/autostart/kite-autostart.desktop
[installer] installed ~/.config/systemd/user/kite-updater.service
[installer] installed ~/.config/systemd/user/kite-updater.timer
[installer] installed ~/.local/share/applications/kite-copilot.desktop
[installer] installed ~/.local/share/applications/kite.desktop
[installer] installed ~/.local/share/icons/hicolor/128x128/apps/kite.png
[installer] installed ~/.local/share/kite/kited
[installer] installed ~/.local/share/kite/uninstall
[installer] installed ~/.local/share/kite/update
[installer] activating kite-updater systemd service
[installer] registering kite:// protocol handler
[installer] kite is installed! launching now! happy coding! :)
Removing kite-installer 
After install you need to use your email to login into Kite account.
The last step is the integrations, and Kite will install this plugin for you. If you use the vim editor, then is a good idea to take a look here.

Thursday, May 2, 2019

Fedora 30 : First test.

Fedora 30 is available now. Use these commands to see how can be updated to Fedora 30.
[root@desk mythcat]# dnf upgrade --refresh 
Waiting for process with pid 2427 to finish.
Adobe Systems Incorporated                      2.4 kB/s | 2.9 kB     00:01    
Fedora Modular 29 - x86_64                       45 kB/s |  25 kB     00:00    
Fedora Modular 29 - x86_64 - Updates             29 kB/s |  24 kB     00:00    
Fedora 29 - x86_64 - Updates                     25 kB/s |  23 kB     00:00    
Fedora 29 - x86_64                               25 kB/s |  25 kB     00:01    
packages-microsoft-com-prod                     6.4 kB/s | 2.9 kB     00:00    
RPM Fusion for Fedora 29 - Free - Updates        13 kB/s |  10 kB     00:00    
RPM Fusion for Fedora 29 - Free                  22 kB/s |  10 kB     00:00    
Visual Studio Code                              8.7 kB/s | 2.9 kB     00:00    
Dependencies resolved.
...
Upgraded:
  selinux-policy-3.14.2-57.fc29.noarch                                          
  selinux-policy-devel-3.14.2-57.fc29.noarch                                    
  selinux-policy-sandbox-3.14.2-57.fc29.noarch                                  
  selinux-policy-targeted-3.14.2-57.fc29.noarch                                 
  x264-libs-0.155-3.20180806git0a84d98.fc29.x86_64                              

Complete!

[root@desk mythcat]# dnf install dnf-plugin-system-upgrade

[root@desk mythcat]# dnf system-upgrade download --releasever=30
Before you continue ensure that your system is fully upgraded by running "dnf --refresh upgrade". 
Do you want to continue [y/N]: y
...
  - problem with installed package python2-libdnf-0.31.0-2.fc29.x86_64
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' 
to skip uninstallable packages)

[root@desk mythcat]# dnf system-upgrade download --releasever=30 --allowerasing
Before you continue ensure that your system is fully upgraded by running "dnf --refresh upgrade". 
Do you want to continue [y/N]: y
...
Transaction Summary
================================================================================
Install      92 Packages
Upgrade    2716 Packages
Remove        8 Packages
Downgrade    22 Packages

Total download size: 2.9 G
DNF will only download packages, install gpg keys, and check the transaction.
Is this ok [y/N]: y
...
Importing GPG key
...
Key imported successfully
Running transaction check
Running transaction test
...
Download complete! Use 'dnf system-upgrade reboot' to start the upgrade.
To remove cached metadata and transaction use 'dnf system-upgrade clean'
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.

Monday, April 29, 2019

Fedora 29 : About poedit tool.

In this tutorial I will briefly introduce the linux poedit tool.
Let's start installing it in Fedora 29.
[root@desk mythcat]# dnf search poedit 
Last metadata expiration check: 0:01:09 ago on Mon 29 Apr 2019 01:23:39 PM EEST.
========================= Name Exactly Matched: poedit =========================
poedit.x86_64 : GUI editor for GNU gettext .po files
[root@desk mythcat]# dnf install poedit 
Last metadata expiration check: 0:02:40 ago on Mon 29 Apr 2019 01:23:39 PM EEST.
Dependencies resolved.
...
Complete!
About this software named Poedit (formerly poEdit) shareware and cross-platform gettext catalog editor to aid in the process of language localization.
Poedit is a powerful and intuitive editor for translating interfaces that use gettext.
Available for Windows, macOS, and Linux.
What is a PO file?
The .PO file is a portable object file, which is text-based. These types of files are used in common in software development. The .PO file may be referenced by Java programs, GNU gettext, or other software programs as a properties file.
What is MO file?
The .MO files or Machine Object is a binary data file that contains object data referenced by a program.
It is typically used to translate program code and may be loaded or imported into the GNU gettext program.

These files can be provided by developer source code or you can sign in into the Crowdin.
This provides powerful tools to manage localization for projects of any type and any size.
Open the application and put all info on from File-> Preferences.
The Poedit asks some of the essential information such as your name, email address, translation memory settings, and more to change your preferences.
Set the path (absolute path) settings in your Catalog otherwise, the Poedit isn't able to use gettext from source files.
Before starting your translate issue be advice with the rules are set by GNU gettext utilities

Sunday, April 14, 2019

Fedora 29 : Install Inkscape with Flatpak Linux tool.

Today I used the Flatpak Linux tool to install the last version of Inkscape 0.92.4 5da689c313 released at 2019-01-14.
Flatpak (formerly xdg-app) is a software utility for software deployment, package management, and application virtualization for Linux desktop computers. It provides a sandbox environment in which users can run applications in isolation from the rest of the system. see Wikipedia Flatpak.
The Flatpak tool is installed by default on Fedora Workstation. To install and runt the last version of Inkscape you need to use these commands:
[mythcat@desk Downloads]$ flatpak install org.inkscape.Inkscape.flatpakref

org.inkscape.Inkscape permissions:
    ipc     x11    file access [1]

    [1] host


        ID                                    Arch   Branch Remote  Download
 1. [✓] org.gnome.Platform.Locale             x86_64 3.30   flathub 17.4 kB / 320.2 MB
 2. [✓] org.freedesktop.Platform.VAAPI.Intel  x86_64 18.08  flathub  1.8 MB / 1.8 MB
 3. [✓] org.freedesktop.Platform.html5-codecs x86_64 18.08  flathub  4.8 MB / 4.9 MB
 4. [✓] org.inkscape.Inkscape                 x86_64 stable flathub 86.1 MB / 88.6 MB
 5. [✓] org.inkscape.Inkscape.Locale          x86_64 stable flathub  8.5 kB / 18.6 MB

Installation complete.

[mythcat@desk Downloads]$ flatpak run org.inkscape.Inkscape
Gtk-Message: 22:58:01.259: Failed to load module "pk-gtk-module"
Gtk-Message: 22:58:01.259: Failed to load module "canberra-gtk-module"
The Inkscape drawing tool works well.

Tuesday, April 9, 2019

Fedora 29 : Thonny editor for python.

This Python IDE for beginners named Thonny is a simple editor with Python 3.7 built in.
The official webpage can be found here and the GitHub project page is this.
The development team is from the University of Tartu, Estonia with the help from the open-source community. Thonny grew up in University of Tartu (https://www.ut.ee), Institute of Computer Science (https://www.cs.ut.ee).
I test it today with Fedora 29 and works well.
Let's start with the first step:
[mythcat@desk ~]$ pip3 install thonny --user
Collecting thonny
...
Successfully installed astroid-2.2.5 asttokens-1.1.13 docutils-0.14 isort-4.3.17 jedi-0.13.3 lazy-object-proxy-1.3.1 
mccabe-0.6.1 mypy-0.700 mypy-extensions-0.4.1 parso-0.4.0 pylint-2.3.1 pyperclip-1.7.0 pyserial-3.4 thonny-3.1.2 
typed-ast-1.3.1
...
[root@desk mythcat]# dnf install python3-tkinter.x86_64
Last metadata expiration check: 0:21:20 ago on Tue 09 Apr 2019 09:57:24 PM EEST.

Installed:
  python3-tkinter-3.7.2-5.fc29.x86_64          tk-1:8.6.8-1.fc29.x86_64         

Complete!
This editor can be found on Fedora repo, but I used the last released version software.
[root@desk mythcat]# dnf search thonny
Last metadata expiration check: 0:36:55 ago on Tue 09 Apr 2019 09:57:24 PM EEST.
========================= Name Exactly Matched: thonny =========================
thonny.noarch : Python IDE for beginners

Thursday, March 21, 2019

Fedora 29 : Testing the dnf python module.

Today we tested with Fedora 29 a python module called DNF.
All users have used this tool.
This python module is not very documented on the internet.
A more complex example can be found on DNF tool documentation.
I tried to see what I can get from this module.
Let's start installing it with the pip tool:
$ pip install dnf --user
Here are some tests that I managed to run in the python shell.
[mythcat@desk ~]$ python
Python 2.7.15 (default, Oct 15 2018, 15:26:09) 
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import dnf
>>> dir(dnf)
['Base', 'Plugin', 'VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 
'__path__', '__version__', 'base', 'callback', 'cli', 'comps', 'conf', 'const', 'crypto', 'db', 
'dnf', 'dnssec', 'drpm', 'exceptions', 'goal', 'history', 'i18n', 'lock', 'logging', 'match_counter',
 'module', 'package', 'persistor', 'plugin', 'pycomp', 'query', 'repo', 'repodict', 'rpm', 'sack',
 'selector', 'subject', 'transaction', 'unicode_literals', 'util', 'warnings', 'yum']
>>> import dnf.conf
>>> print(dnf.conf.Conf())
[main]
assumeno: 0
assumeyes: 0
autocheck_running_kernel: 1
bandwidth: 0
best: 0
...
>>> import dnf.module
>>> import dnf.rpm
>>> import dnf.cli
>>> base = dnf.Base()
>>> base.update_cache()
True
This read all repositories:

>>> base.read_all_repos()
You need to read the sack for querying:

>>> base.fill_sack()

>>> base.sack_activation = True
Create a query to matches all packages in sack:

>>> qr=base.sack.query() 
Get only available packages:

>>> qa=qr.available() 
Get only installed packages:

>>> qi=qr.installed()
>>> q_a=qa.run()
>>> for pkg in qi.run():
...     if pkg not in q_a:
...             print('%s.%s' % (pkg.name, pkg.arch))
... 
NetworkManager-openvpn.x86_64
NetworkManager-openvpn-gnome.x86_64
coolkey.x86_64
glibc-debuginfo.x86_64
glibc-debuginfo-common.x86_64
kernel.x86_64
kernel.x86_64
kernel-core.x86_64
kernel-core.x86_64
Get all packages installed on Linux:

>>> q_i=qi.run()
>>> for pkg in qi.run():
...     print('%s.%s' % (pkg.name, pkg.arch))
You can see more about the Python programming language on my blog.

Wednesday, March 13, 2019

Fedora 29 : Use Selinux with Firefox.

Today I tested Selinux with the Firefox browser. The main purpose was to create a policy for this browser. You can use this example to create your own policies. Using Fedora 29 this problem can be resolved easily. Let's start with installing an important packet using the dnf tool.
[root@desk selinux_001]# dnf install policycoreutils-devel
Let's see the other commands used to create policies named firefox.te:
[mythcat@desk ~]$ mkdir selinux_001
[mythcat@desk ~]$ cd selinux_001/
[mythcat@desk selinux_001]$ whereis firefox
firefox: /usr/bin/firefox /usr/lib64/firefox /etc/firefox /usr/share/man/man1/firefox.1.gz
[mythcat@desk selinux_001]$ sepolicy generate --init -n firefox /usr/bin/firefox 
nm: /usr/bin/firefox: file format not recognized
Failed to retrieve rpm info for selinux-policy
Created the following files:
/home/mythcat/selinux_001/firefox.te # Type Enforcement file
/home/mythcat/selinux_001/firefox.if # Interface file
/home/mythcat/selinux_001/firefox.fc # File Contexts file
/home/mythcat/selinux_001/firefox_selinux.spec # Spec file
/home/mythcat/selinux_001/firefox.sh # Setup Script
[mythcat@desk selinux_001]$ cat firefox.te


policy_module(firefox, 1.0.0)

########################################
#
# Declarations
#

type firefox_t;
type firefox_exec_t;
init_daemon_domain(firefox_t, firefox_exec_t)

permissive firefox_t;

########################################
#
# firefox local policy
#
allow firefox_t self:fifo_file rw_fifo_file_perms;
allow firefox_t self:unix_stream_socket create_stream_socket_perms;

domain_use_interactive_fds(firefox_t)

files_read_etc_files(firefox_t)

miscfiles_read_localization(firefox_t)
[mythcat@desk selinux_001]$ cat firefox.fc 
/usr/bin/firefox        --    gen_context(system_u:object_r:firefox_exec_t,s0)
I have modified this policy generated by sepolicy by adding my own rules:
[mythcat@desk selinux_001]$ cat firefox.te
policy_module(firefox, 1.0.0)

########################################
#
# Declarations
#

type firefox_t;
type firefox_exec_t;
init_daemon_domain(firefox_t, firefox_exec_t)

permissive firefox_t;
# my rules
require {
    type unreserved_port_t;
    type http_port_t;
    class tcp_socket { accept listen name_bind name_connect };
}

########################################
#
# firefox local policy
#
allow firefox_t self:fifo_file rw_fifo_file_perms;
allow firefox_t self:unix_stream_socket create_stream_socket_perms;

# my rules
allow firefox_t http_port_t:tcp_socket { name_bind name_connect };
allow firefox_t unreserved_port_t:tcp_socket { name_bind name_connect };
allow firefox_t self:tcp_socket { listen accept };

domain_use_interactive_fds(firefox_t)

files_read_etc_files(firefox_t)

miscfiles_read_localization(firefox_t)
I used the following commands to get my own policy:
[mythcat@desk selinux_001]$ make -f /usr/share/selinux/devel/Makefile
Compiling targeted firefox module
/usr/bin/checkmodule:  loading policy configuration from tmp/firefox.tmp
/usr/bin/checkmodule:  policy configuration loaded
/usr/bin/checkmodule:  writing binary representation (version 19) to tmp/firefox.mod
Creating targeted firefox.pp policy package
rm tmp/firefox.mod tmp/firefox.mod.fc
[mythcat@desk selinux_001]$ sudo semodule -i firefox.pp
[sudo] password for mythcat: 
The semodule is the tool used to manage SELinux policy modules, including installing, upgrading, listing and removing modules. Let's see the result:
[root@desk selinux_001]# semodule -l | grep firefox
firefox

Friday, February 1, 2019

Fedora 29 : The Piskel application.

This application is a tool for drawing and create sprites.
You can test online or use it locally by download it into your operating system.
The development team comes with this intro:
Create animations in your browser. Try an example, use Google sign in to access your gallery or simply create a new sprite.
I download it to Fedora 29 distro and working well.
This is result:

Thursday, January 24, 2019

Fedora 29 : Selinux and python.

Today I tested the selinux python module with Fedora 29.
The wikipedia page comes with this intro about SELinux: Security-Enhanced Linux (SELinux) is a Linux kernel security module that provides a mechanism for supporting access control security policies, including mandatory access controls (MAC). ... A Linux kernel integrating SELinux enforces mandatory access control policies that confine user programs and system services, as well as access to files and network resources.

This kernel module can help you with security the network and running application on your Linux.
This very complex kernel module can be used with your policy configuration files designed to fix your security issues.
First, the install is easy to do with the dnf tool:
[root@desk mythcat]# dnf install python2-libselinux.x86_64 
Last metadata expiration check: 1:31:46 ago on Thu 24 Jan 2019 07:04:16 AM EET.
Dependencies resolved.
...
Installed:
  python2-libselinux-2.8-6.fc29.x86_64                                          

Complete!
I tested this python module with a few simple examples:
[mythcat@desk ~]$ python 
Python 2.7.15 (default, Oct 15 2018, 15:26:09) 
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import selinux
>>> selinux.is_selinux_enabled()
1
>>> selinux.lgetfilecon_raw(".bashrc")
[37, 'unconfined_u:object_r:user_home_t:s0']
>>> selinux.lgetfilecon_raw(".bashrc")
[37, 'unconfined_u:object_r:user_home_t:s0']
>>> selinux.selinux_getpolicytype()[1]
'targeted'
>>> selinux.selinux_getpolicytype()
[0, 'targeted']

Sunday, January 13, 2019

Fedora 29 : The AppImage tool and Krita Next.

The AppImage is a universal software package format.
The process of packaging the software in AppImage is a storage file provide by the developer.
This file is a compressed image with all the dependencies and libraries needed to run the desired software. The AppImage doesn’t really install the software just execute it without no extraction and no installation.
The most common features:
  • Can run on various different Linux distributions;
  • No need of installing and compiling software;
  • No need of root permission and the system files are not touched;
  • Can be run anywhere including live disks;
  • Applications are in read only mode;
  • Software are removed just by just deleting the AppImage file;
  • Applications packaged in AppImage are not sandboxed by default.
More about this can be read at official webpage.
I tested the Krita Next with this tool.
The appimage file of Krita Next can be found here.
About the Krita Next this is a daily builds that contain new features, but could be unstable.
After I download the file I change it to executable with:
[mythcat@desk Downloads]$ chmod +x krita-4.2.0-pre-alpha-95773b5-x86_64.appimage 
[mythcat@desk Downloads]$ ./krita-4.2.0-pre-alpha-95773b5-x86_64.appimage

Monday, January 7, 2019

Fedora 29 : The figlet linux tool.

About this Linux tool you can read at figlet manual :
FIGlet prints its input using large characters (called ``FIGcharac- ters'')made up of ordinary screen characters (called ``sub-charac- ters''). FIGlet output is generally reminiscent of the sort of ``sig- natures'' many people like to put at the end of e-mail and UseNet mes- sages. It is also reminiscent of the output of some banner programs, although it is oriented normally, not sideways. 
...
Let's see some examples:
[root@desk mythcat]# dnf install figlet
Last metadata expiration check: 1:05:53 ago on Mon 07 Jan 2019 06:52:19 PM EET.
Dependencies resolved.

[mythcat@desk ~]$ figlet --h
figlet: invalid option -- '-'
Usage: figlet [ -cklnoprstvxDELNRSWX ] [ -d fontdirectory ]
              [ -f fontfile ] [ -m smushmode ] [ -w outputwidth ]
              [ -C controlfile ] [ -I infocode ] [ message ]

                  

[mythcat@desk ~]$ figlet -v 
FIGlet Copyright (C) 1991-2012 Glenn Chappell, Ian Chai, John Cowan,
Christiaan Keet and Claudio Matsuoka
Internet:  Version: 2.2.5, date: 31 May 2012

FIGlet, along with the various FIGlet fonts and documentation, may be
freely copied and distributed.

If you use FIGlet, please send an e-mail message to .

The latest version of FIGlet is available from the web site,
    http://www.figlet.org/

Usage: figlet [ -cklnoprstvxDELNRSWX ] [ -d fontdirectory ]
              [ -f fontfile ] [ -m smushmode ] [ -w outputwidth ]
              [ -C controlfile ] [ -I infocode ] [ message ]
The messages can be set and show on output like a print similar to an ASCII banner.
The arguments of this tool set to the left, center and right or change size and font:
The simple one can be this:
[mythcat@desk ~]$ figlet 2019

Friday, December 28, 2018

Fedora 29 : The most common BIOS commands.

Fedora Distribution has many things that many overlook in the maintenance process.
Today I will show you some commands for your BIOS.
These are fairly common and are fairly recent.
First is efibootmgr:
[root@desk mythcat]# efibootmgr
EFI variables are not supported on this system.
The next one is dmidecode, see:
[root@desk mythcat]# dmidecode -t 11
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 2.4 present.
[root@desk mythcat]# dmidecode --type processor
# dmidecode 3.2
...
The dmidecode command can be used with the arg -t from 0 to 39, or you can use the --type with this keywords:
  • baseboard
  • bios
  • cache
  • chassis;
  • connector
  • memory
  • processor
  • slot
  • system
The last one I used with Fedora 29 is biosdecode.
The dmidecode and biosdecode commands are Linux distro independent and preinstalled in most of them.
Let's see commands that depend on hardware.
The vpddecode command for IBM and Lenovo hardware only, the vpd stands for vital product data.
The ownership command is for only Compaq hardware, to get Compaq specific ownership tag info.

Wednesday, December 12, 2018

Fedora 29 : Using pytorch on Fedora distro.

The goal of this tutorial is about how to install and start using the pytorch python module.
Another part is to show tensors without using matplotlib python module.
The reason I wrote this simple tutorial and not on my python blogger is Fedora distro.
The python module named pytorch is based on Torch, used for applications such as natural language processing.
The installation of pytorch into many operating systems can be tricky.
Let's start this tutorial using GitHub clone commands:
[mythcat@desk ~]$  git clone --recursive https://github.com/pytorch/pytorch
...
running install_scripts
Installing convert-caffe2-to-onnx script to /home/mythcat/.local/bin
Installing convert-onnx-to-caffe2 script to /home/mythcat/.local/bin
Using this commands un Fedora linux shell will install easy this python module:
[mythcat@desk ~]$  cd pytorch/
[mythcat@desk ~]$ pip install typing
[mythcat@desk ~]$ python setup.py install --user
[mythcat@desk ~]$ pip install torchvision --user
Collecting torchvision
...
You cannot use the pytorch into pytorch folder.
[mythcat@desk pytorch]$ cd ..
[mythcat@desk ~]$ python -c "import torch; print(torch.__version__)"
1.0.0a0+bf1d411
The result of this output is not an common error. You can fix if you set the paths for pytorch installation. Let's test the pytorch installation:
[mythcat@desk ~]$ python
Python 2.7.15 (default, Oct 15 2018, 15:26:09) 
[GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch 
>>> import torchvision
>>> import torchvision.dataset as datasets
Traceback (most recent call last):
  File "", line 1, in 
ImportError: No module named dataset
>>> import torchvision.datasets as datasets
>>> print(dir(torch))
['Argument', 'ArgumentSpec', 'Block', 'BoolType', 'ByteStorage', 'ByteTensor', 'CharStorage', 'CharTensor', 'Code', 
'CompleteArgumentSpec', 'DoubleStorage', 'DoubleTensor', 'DynamicType', 'ExecutionPlanState', 'FatalError', 'FloatStorage',
 'FloatTensor', 'FloatType', 'FunctionSchema', 'Future', 'Generator', 'Gradient', 'Graph', 'GraphExecutor', 
'GraphExecutorState', 'HalfStorage', 'HalfStorageBase', 'HalfTensor', 'IODescriptor', 'IntStorage', 'IntTensor', 'IntType',
 'JITException', 'ListType',
...
>>> print(dir(datasets))
['CIFAR10', 'CIFAR100', 'CocoCaptions', 'CocoDetection', 'DatasetFolder', 'EMNIST', 'FakeData', 'FashionMNIST', 
'ImageFolder', 'LSUN', 'LSUNClass', 'MNIST', 'Omniglot', 'PhotoTour', 'SEMEION', 'STL10', 'SVHN', '__all__', 
'__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'cifar', 'coco', 'fakedata', 
'folder', 'lsun', 'mnist', 'omniglot', 'phototour', 'semeion', 'stl10', 'svhn', 'utils']
>>> x = torch.rand(76)
>>> x.size()
>>> print(x)
tensor([0.9839, 0.5844, 0.4347, 0.5883, 0.1383, 0.7701, 0.1879, 0.5604, 0.4486,
        0.6782, 0.5038, 0.1078, 0.1244, 0.0996, 0.0230, 0.5457, 0.8903, 0.7732,
        0.9948, 0.3201, 0.3149, 0.7180, 0.8811, 0.4468, 0.8169, 0.2998, 0.3900,
        0.8067, 0.0090, 0.6006, 0.8385, 0.8786, 0.3652, 0.5630, 0.1407, 0.7747,
        0.5734, 0.4998, 0.4056, 0.7473, 0.2797, 0.8852, 0.3563, 0.9421, 0.1136,
        0.7676, 0.4224, 0.4350, 0.4968, 0.4457, 0.3047, 0.6792, 0.1026, 0.3593,
        0.4147, 0.6517, 0.5916, 0.3567, 0.8584, 0.9421, 0.2091, 0.6339, 0.5428,
        0.3811, 0.9310, 0.8856, 0.0770, 0.7920, 0.4860, 0.4276, 0.4780, 0.8627,
        0.7287, 0.4340, 0.2859, 0.2213])
>>> from PIL import Image
>>> logo = np.array(Image.open('logo.png').resize((512,512)))
>>> logo_tensor = torch.from_numpy(logo)
>>> logo_tensor.size()
(512, 512, 4)
>>> img = Image.fromarray(logo)
>>> img.show()

Sunday, December 9, 2018

Fedora 29 : Python 3 and Jupyter notebook.

Today I tested the Jupyter Notebook with Fedora 29.
About the Jupyter Notebook the official website comes with this intro:
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
First I check with DNF tool the update and the upgrade of the Fedora 29 distro.
The next step was to install this:
# dnf install python3-pip
# dnf install python3-devel.x86_64
# pip3 install --upgrade pip
With my account shell I used this commands to create and run the Jupiter Notebook:
$ pip3 install --user virtualenv
$ mkdir my_project
$ cd my_project/
$ virtualenv my_project_env
$ source my_project_env/bin/activate
$ pip3 install jupiter
$ jupiter notebook
The last command will start your default browser and will see this:
You can see I created a new notebook with Python 3.
The result is shown into another tab webpage browser where I used few commands to install new module scipy and I check if this working well:
!pip3 install scipy
help
quickref
The result of this notebook looks like this image: