computerの日記

Cisco,SHELL,C,Qt,C++,Linux,ネットワーク,Windows Scriptなどの発言です

dbus を使ってみる(その1)

お疲れさまです、私です。

segatex-ng に何をさせようかと考えていたんですが、dbus に流れている何かのデータをどうにかする、ってのを考えました。

まず、d-feet をインストールしました。

Fedora26 では、簡単にインストールできました。

d-feet を立ち上げて、どんなものがあるのかを、確認しました。

org.freedesktop.Notifications というのがありました。

なんだか分かりませんが、これな何を流しているのか、確認してみようと思いました。

ネットで検索したところ、いいチュートリアルがありました。

cheesehead-techblog.blogspot.jp

ここのサイトをなんとなく翻訳すると、怒られそうで、やらないです。皆さんの方で、じっくり読んんでみてくださいね。

では、やってみます。

やりかたは、d-feet の表示画面であたりをつけて、コマンドを打ってみるやり方です。

org.freedesktop.Notifications が、何かを notify していそうなので、man dbus-send と、紹介したチュートリアルを読んで、自分なりに文法に則り構文を組み立ててみました。

以下のようなコマンドを発行して、このような値が返却されたようです。

$ dbus-send --session --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.GetServerInformation

(結果)
method return time=1503141720.720741 sender=:1.100 -> destination=:1.112 serial=21 reply_serial=2
string "Xfce Notify Daemon"
string "Xfce"
string "0.3.6"
string "0.9"

 

なるほど、なんとなくおもしろそうですね。

お疲れさまです。私、でした。

次回をお楽しみに。

SELinux が有効で動作する、SHIRASAGI インストーラーの話

こんにちは、私です。

 

SHIRASAGI は、オープンソースCMS ですが、 付属しているインストーラーは、CentOS 用のものといえ、SELinux を有無を言わさず無効にする、というものです。

 

これに疑問を持った私は、逆に、SELinux が有効なら動くインストーラーを作りました。なお、SELinux が無効な場合には無理矢理有効にしたりしませんので、ご安心ください。

 

何かありましたらお知らせください。

github.com

 

smartctl で test を実行してみた

こんにちは、私です。

smartctl を、自分のコンピュータで実行してみました。

# smartctl --test=short /dev/sda

smartctl 6.5 2016-05-07 r4318 [x86_64-linux-4.11.10-300.fc26.x86_64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF OFFLINE IMMEDIATE AND SELF-TEST SECTION ===
Sending command: "Execute SMART Short self-test routine immediately in off-line mode".
Drive command "Execute SMART Short self-test routine immediately in off-line mode" successful.
Testing has begun.
Please wait 1 minutes for test to complete.
Test will complete after Sun Jul 23 10:40:42 2017

Use smartctl -X to abort test.

sort テストを実行したのですが、「Please wait 1 minutes」 ということなので、数分待って、
以下のコマンドを実行しました。

# smartctl -a /dev/sda

smartctl 6.5 2016-05-07 r4318 [x86_64-linux-4.11.10-300.fc26.x86_64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     KINGSTON RBU-SNS8152S3256GG2
Serial Number:    50026B726B05B77B
Firmware Version: SAFM01.R
User Capacity:    256,060,514,304 bytes [256 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      M.2
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sun Jul 23 10:40:18 2017 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
See vendor-specific Attribute list for marginal Attributes.

General SMART Values:
Offline data collection status:  (0x00)    Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
Self-test execution status:      ( 241)    Self-test routine in progress...
                    10% of test remaining.
Total time to complete Offline
data collection:         (   30) seconds.
Offline data collection
capabilities:              (0x79) SMART execute Offline immediate.
                    No Auto Offline data collection support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    Conveyance Self-test supported.
                    Selective Self-test supported.
SMART capabilities:            (0x0003)    Saves SMART data before entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01)    Error logging supported.
                    General Purpose Logging supported.
Short self-test routine
recommended polling time:      (   1) minutes.
Extended self-test routine
recommended polling time:      (   2) minutes.
Conveyance self-test routine
recommended polling time:      (   3) minutes.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   050    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0005   100   100   050    Pre-fail  Offline      -       0
  3 Spin_Up_Time            0x0007   100   100   050    Pre-fail  Always       -       0
  5 Reallocated_Sector_Ct   0x0013   100   100   050    Pre-fail  Always       -       0
  7 Unknown_SSD_Attribute   0x000b   100   100   050    Pre-fail  Always       -       0
  8 Unknown_SSD_Attribute   0x0005   100   100   050    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       2781
 12 Power_Cycle_Count       0x0012   100   100   000    Old_age   Always       -       199
168 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       0
170 Unknown_Attribute       0x0003   100   100   010    Pre-fail  Always       -       333
173 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       1769543
175 Program_Fail_Count_Chip 0x0013   100   100   050    Pre-fail  Always       -       0
187 Reported_Uncorrect      0x0012   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0012   100   100   000    Old_age   Always       -       34
194 Temperature_Celsius     0x0023   041   030   030    Pre-fail  Always   In_the_past 59 (Min/Max 18/70)
196 Reallocated_Event_Count 0x0002   100   100   010    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
199 UDMA_CRC_Error_Count    0x000b   100   100   050    Pre-fail  Always       -       0
218 Unknown_Attribute       0x000b   100   100   050    Pre-fail  Always       -       0
231 Temperature_Celsius     0x0013   100   100   000    Pre-fail  Always       -       100
233 Media_Wearout_Indicator 0x000b   100   100   000    Pre-fail  Always       -       977
240 Unknown_SSD_Attribute   0x0013   100   100   000    Pre-fail  Always       -       0
241 Total_LBAs_Written      0x0012   100   100   000    Old_age   Always       -       6665
242 Total_LBAs_Read         0x0012   100   100   000    Old_age   Always       -       1824
244 Unknown_Attribute       0x0002   100   100   000    Old_age   Always       -       27
245 Unknown_Attribute       0x0002   100   100   000    Old_age   Always       -       71
246 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       1886464

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

[root@localhost fujiwara]# smartctl -a /dev/sda
smartctl 6.5 2016-05-07 r4318 [x86_64-linux-4.11.10-300.fc26.x86_64] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     KINGSTON RBU-SNS8152S3256GG2
Serial Number:    50026B726B05B77B
Firmware Version: SAFM01.R
User Capacity:    256,060,514,304 bytes [256 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      M.2
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ACS-2 (minor revision not indicated)
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Sun Jul 23 10:40:33 2017 JST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
See vendor-specific Attribute list for marginal Attributes.

General SMART Values:
Offline data collection status:  (0x00)    Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
Self-test execution status:      (   0)    The previous self-test routine completed
                    without error or no self-test has ever
                    been run.
Total time to complete Offline
data collection:         (   30) seconds.
Offline data collection
capabilities:              (0x79) SMART execute Offline immediate.
                    No Auto Offline data collection support.
                    Suspend Offline collection upon new
                    command.
                    Offline surface scan supported.
                    Self-test supported.
                    Conveyance Self-test supported.
                    Selective Self-test supported.
SMART capabilities:            (0x0003)    Saves SMART data before entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01)    Error logging supported.
                    General Purpose Logging supported.
Short self-test routine
recommended polling time:      (   1) minutes.
Extended self-test routine
recommended polling time:      (   2) minutes.
Conveyance self-test routine
recommended polling time:      (   3) minutes.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate     0x000b   100   100   050    Pre-fail  Always       -       0
  2 Throughput_Performance  0x0005   100   100   050    Pre-fail  Offline      -       0
  3 Spin_Up_Time            0x0007   100   100   050    Pre-fail  Always       -       0
  5 Reallocated_Sector_Ct   0x0013   100   100   050    Pre-fail  Always       -       0
  7 Unknown_SSD_Attribute   0x000b   100   100   050    Pre-fail  Always       -       0
  8 Unknown_SSD_Attribute   0x0005   100   100   050    Pre-fail  Offline      -       0
  9 Power_On_Hours          0x0012   100   100   000    Old_age   Always       -       2781
 12 Power_Cycle_Count       0x0012   100   100   000    Old_age   Always       -       199
168 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       0
170 Unknown_Attribute       0x0003   100   100   010    Pre-fail  Always       -       333
173 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       1769543
175 Program_Fail_Count_Chip 0x0013   100   100   050    Pre-fail  Always       -       0
187 Reported_Uncorrect      0x0012   100   100   000    Old_age   Always       -       0
192 Power-Off_Retract_Count 0x0012   100   100   000    Old_age   Always       -       34
194 Temperature_Celsius     0x0023   040   030   030    Pre-fail  Always   In_the_past 60 (Min/Max 18/70)
196 Reallocated_Event_Count 0x0002   100   100   010    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
199 UDMA_CRC_Error_Count    0x000b   100   100   050    Pre-fail  Always       -       0
218 Unknown_Attribute       0x000b   100   100   050    Pre-fail  Always       -       0
231 Temperature_Celsius     0x0013   100   100   000    Pre-fail  Always       -       100
233 Media_Wearout_Indicator 0x000b   100   100   000    Pre-fail  Always       -       977
240 Unknown_SSD_Attribute   0x0013   100   100   000    Pre-fail  Always       -       0
241 Total_LBAs_Written      0x0012   100   100   000    Old_age   Always       -       6665
242 Total_LBAs_Read         0x0012   100   100   000    Old_age   Always       -       1824
244 Unknown_Attribute       0x0002   100   100   000    Old_age   Always       -       27
245 Unknown_Attribute       0x0002   100   100   000    Old_age   Always       -       71
246 Unknown_Attribute       0x0012   100   100   000    Old_age   Always       -       1886464

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num  Test_Description    Status                  Remaining  LifeTime(hours)  LBA_of_first_error
# 1  Short offline       Completed without error       00%      2781         -

SMART Selective self-test log data structure revision number 1
 SPAN  MIN_LBA  MAX_LBA  CURRENT_TEST_STATUS
    1        0        0  Not_testing
    2        0        0  Not_testing
    3        0        0  Not_testing
    4        0        0  Not_testing
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

(参考)
man 8 smartctl

Django で作ったページからメールを送信しようと思ったらエラーとなったので、boolean を on にした件

SELinux を使うのは、常識なので、以下の指示に従えば良い。

SELinux is preventing httpd from name_connect access on the tcp_socket port 25.

*****  Plugin catchall_boolean (32.5 confidence) suggests   ******************

If allow httpd to can network connect がしたい
Then 'httpd_can_network_connect' boolean を有効にすることにより、 これを SELinux に伝える必要があります。
詳細情報については、'None' man ページをご覧下さい。
Do
setsebool -P httpd_can_network_connect 1

*****  Plugin catchall_boolean (32.5 confidence) suggests   ******************

If allow httpd to can sendmail がしたい
Then 'httpd_can_sendmail' boolean を有効にすることにより、 これを SELinux に伝える必要があります。
詳細情報については、'None' man ページをご覧下さい。
Do
setsebool -P httpd_can_sendmail 1

*****  Plugin catchall_boolean (32.5 confidence) suggests   ******************

If allow nis to enabled がしたい
Then 'nis_enabled' boolean を有効にすることにより、 これを SELinux に伝える必要があります。
詳細情報については、'None' man ページをご覧下さい。
Do
setsebool -P nis_enabled 1

*****  Plugin catchall (4.5 confidence) suggests   ***************************

If httpd に、 port 25 tcp_socket の name_connect アクセスがデフォルトで許可されるべきです。   
Then バグとして報告してください。
ローカルのポリシーモジュールを生成すると、
 このアクセスを許可することができます。
Do
allow this access for now by executing:
# ausearch -c 'httpd' --raw | audit2allow -M my-httpd
# semodule -X 300 -i my-httpd.pp

Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                system_u:object_r:smtp_port_t:s0
Target Objects                port 25 [ tcp_socket ]
Source                        httpd
Source Path                   httpd
Port                          25
Host                          localhost.localdomain
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-225.6.fc25.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     localhost.localdomain
Platform                      Linux localhost.localdomain 4.8.13-300.fc25.x86_64
                              #1 SMP Fri Dec 9 14:52:00 UTC 2016 x86_64 x86_64
Alert Count                   1
First Seen                    2017-01-14 14:30:13 JST
Last Seen                     2017-01-14 14:30:13 JST
Local ID                      8ecd91ba-83b6-4569-ab67-c5249ee8b36b

Raw Audit Messages
type=AVC msg=audit(1484371813.32:361): avc:  denied  { name_connect } for  pid=9405 comm="httpd" dest=25 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:smtp_port_t:s0 tclass=tcp_socket permissive=0


Hash: httpd,httpd_t,smtp_port_t,tcp_socket,name_connect

Django でつくったページの表示に失敗 ImportError: No module named 'xxxx'

Django でつくったページの表示に失敗していたが、以下で直った。

[wsgi:error] [pid ----] [client 127.0.0.1:37588] ImportError: No module named 'xxxx'

とモジュールが読めないとエラーが出て行た。

当該プログラムのwsgi.py に、

sys.path.append ..... としたら解決した。

import os,sys

from django.core.wsgi import get_wsgi_application
sys.path.append("/var/www/xxxx")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xxxx.settings")

application = get_wsgi_application()