ol-consolebaud.service: main process exited, code=exited, status=1/FAILURE
Failed to start Check console baud rate.
Unit ol-consolebaud.service entered failed state.
ol-consolebaud.service failed.
$ sudo dnf update oci-utils -y
Last metadata expiration check: 4:26:16 ago on Tue 08 Jun 2021 01:30:06 PM JST.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Upgrading:
oci-utils noarch 0.12.4-1.el8 ol8_oci_included 245 k
Installing dependencies:
python3-arrow noarch 0.17.0-1.0.1.el8 ol8_oci_included 101 k
python3-click noarch 6.7-8.el8 ol8_appstream 131 k
python3-convertdate noarch 2.3.0-1.0.1.el8 ol8_oci_included 83 k
python3-dateparser noarch 1.0.0-1.0.1.el8 ol8_oci_included 392 k
python3-hijri-converter noarch 2.1.1-1.0.1.el8 ol8_oci_included 30 k
python3-jmespath noarch 0.10.0-1.el8 ol8_oci_included 48 k
python3-pymeeus noarch 0.3.6-2.0.1.el8 ol8_oci_included 1.1 M
python3-regex aarch64 2021.4.4-1.el8 ol8_developer_EPEL 328 k
python3-retrying noarch 1.3.3-1.0.1.el8 ol8_oci_included 22 k
python3-terminaltables noarch 3.1.0-1.0.1.el8 ol8_oci_included 31 k
python3-tzlocal noarch 2.0.0-4.el8 ol8_oci_included 37 k
python36-oci-cli noarch 2.22.1-1.el8 ol8_oci_included 6.4 M
Transaction Summary
================================================================================
Install 12 Packages
Upgrade 1 Package
Total download size: 8.9 M
<略>
$
$ oci ons message publish --topic-id ocid1.onstopic.oc1.ap-tokyo-1.<略> --title "test mail" --body "test mail"
ERROR: Could not find config file at /home/opc/.oci/config, please follow the instructions in the link to setup the config file https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm
$
$ oci setup keys
Enter a passphrase for your private key (empty for no passphrase):
Public key written to: /home/opc/.oci/oci_api_key_public.pem
Private key written to: /home/opc/.oci/oci_api_key.pem
Public key fingerprint: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
If you haven't already uploaded your API Signing public key through the
console, follow the instructions on the page linked below in the section
'How to upload the public key':
https://docs.cloud.oracle.com/Content/API/Concepts/apisigningkey.htm#How2
$ ls -al ~/.oci
total 8
drwx------. 2 opc opc 59 Jun 7 17:32 .
drwx------. 5 opc opc 138 Jun 7 17:32 ..
-rw-------. 1 opc opc 1679 Jun 7 17:32 oci_api_key.pem
-rw-------. 1 opc opc 451 Jun 7 17:32 oci_api_key_public.pem
$
$ oci ons message publish --topic-id ocid1.onstopic.oc1.ap-tokyo-1.aa<略> --title "test mail" --body "test mail"
WARNING: Permissions on /home/opc/.oci/config are too open.
To fix this please try executing the following command:
oci setup repair-file-permissions --file /home/opc/.oci/config
Alternatively to hide this warning, you may set the environment variable, OCI_CLI_SUPPRESS_FILE_PERMISSIONS_WARNING:
export OCI_CLI_SUPPRESS_FILE_PERMISSIONS_WARNING=True
{
"data": {
"message-id": "56ca7636-1605-7a19-5344-<略>",
"time-stamp": null
}
}
$
まず、「WARNING: Permissions on /home/opc/.oci/config are too open.」についてはパーミッション問題なので、書いてある通りに対処する。
$ ls -l /home/opc/.oci/config
-rw-rw-rw-. 1 opc opc 299 Jun 7 17:43 /home/opc/.oci/config
$ oci setup repair-file-permissions --file /home/opc/.oci/config
$ ls -l /home/opc/.oci/config
-rw-------. 1 opc opc 299 Jun 7 17:43 /home/opc/.oci/config
$
$ sudo vi /usr/local/bin/oci-notification-mail
$ cat /usr/local/bin/oci-notification-mail
#!/usr/bin/python3
# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).
import oci
import sys
argvs=sys.argv
argc = len(argvs)
subject=argvs[1]
textbody="".join(sys.stdin.readlines())
# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()
# Initialize service client with default config file
ons_client = oci.ons.NotificationDataPlaneClient(config)
# Send the request to service, some parameters are not required, see API
# doc for more info
publish_message_response = ons_client.publish_message(
topic_id="ocid1.onstopic.oc1.ap-tokyo-1.<略>",
message_details=oci.ons.models.MessageDetails(
body=textbody,
title=subject),
message_type="RAW_TEXT")
# Get the data from response
print(publish_message_response.data)
$ sudo chmod a+x /usr/local/bin/oci-notification-mail
$
# Sample configuration file for ESMTP.
#
# Jose Fonseca
# Set SMTP host and service (port)
#
hostname = localhost:25
# Set the user name
#
username = "USERNAME"
# Set the password
password = "PASSWORD"
# Use the Starttls
#
#starttls = disabled
#
# It can be one of "enabled", "disabled" or "required". It defaults to
# disabled.
# Set the certificate passphrase
#
#certificate_passphrase = "CERTIFICATE_PASSPHRASE"
# Command to run before contacting the SMTP server
#
#preconnect = "ssh -f -L 2025:mail.isp.com:25 user@shell.isp.com 'sleep 5'"
# Same as above but for a different identity which can be selected with the
# '-f' flag. You can have as many you like.
#
identity = myself@somewhere.com
hostname = smtp.somewhere.com:25
username = "myself"
password = "secret"
#starttls = disabled
#
# NOTE: the default indentity settings aren't shared by the other identities.
# Everything (username, password, etc.) must be specified for every identity
# even if they don't differ from the default identity.
# Set the Mail Delivery Agent (MDA)
#
mda = "/usr/bin/procmail -d %T"
#
# Some possible MDAs are "/usr/bin/procmail -d %T", "/usr/bin/deliver" or
# "/usr/lib/mail.local %T".
さて、Oracle Linux 7環境でesmtpを設定してみたところ、cronで送られてくるメールが送信できていないようだ。
/etc/cron.daily/0logwatch:
You have old files in your logwatch tmpdir (/var/cache/logwatch):
logwatch.idrC25J0
logwatch.Hb7DUNNO
The directories listed above were most likely created by a
logwatch run that failed to complete successfully. If so, you
may delete these directories.
/bin/mktemp: failed to create directory via template '/root/.esmtp_queue/XXXXXXX
X': Permission denied
unable to create tempdir inside /root/.esmtp_queue
/etc/cron.daily/0yum-daily.cron:
# grep deni /var/log/audit/audit.log*|grep mail_home_rw_t
#============= logwatch_t ==============
#!!!! This avc is allowed in the current policy
allow logwatch_t mail_home_rw_t:dir create;
allow logwatch_t mail_home_rw_t:file create;
# grep deni /var/log/audit/audit.log*|grep mail_home_rw_t | audit2allow -M mktemp
******************** IMPORTANT ***********************
To make this policy package active, execute:
semodule -i mktemp.pp
# semodule -i mktemp.pp
# semodule -l | mktemp
mktemp 1.0
#
ただ、1回だけではだめで、何回か追加を繰り替えすことになった。
最終的に作成された mktemp.te ファイルは下記となった。
module mktemp 1.0.8;
require {
type logwatch_t;
type mail_home_rw_t;
class file { create link open read setattr unlink write };
class dir { add_name create read remove_name rmdir write };
}
#============= logwatch_t ==============
#!!!! This avc is allowed in the current policy
allow logwatch_t mail_home_rw_t:dir { add_name create read remove_name rmdir write };
#!!!! This avc is allowed in the current policy
allow logwatch_t mail_home_rw_t:file { create link open read setattr unlink write };