divide smack rules for dlogutil and libdlog
authorjuho <juho80.son@samsung.com>
Tue, 12 Mar 2013 07:40:09 +0000 (16:40 +0900)
committerjuho <juho80.son@samsung.com>
Tue, 12 Mar 2013 07:44:54 +0000 (16:44 +0900)
modified smak rules
add SECLOG for secure log
modified dlogutil checking dump option and exit code,when it save rotate log files.
modified dloglevel file position.

Change-Id: Icc8672745e6498e7cdd69dbfe93870a633fdf977

include/dlog.h
log.c
logutil.c
packaging/dlog.spec
packaging/dlogutil.manifest [moved from dlogutil.manifest with 74% similarity]
packaging/libdlog.manifest [new file with mode: 0644]
packaging/tizen-debug-level.service
tizen_platform_env.sh

index b1c566f..8fe6647 100755 (executable)
@@ -91,6 +91,22 @@ typedef enum {
 
 // ---------------------------------------------------------------------
 /**
+ * Secure Log Macro.
+ */
+
+#define _SECURE_LOG 1
+
+#ifndef SECLOG
+#if _SECURE_LOG
+#define SECLOG(...)   (0)
+#else
+#define SECLOG(format, arg...) \
+       (LOG_ON() ? (SLOG(LOG_WARN, LOG_TAG, "%s: %s(%d) > " format, __MODULE__, __func__, __LINE__, ##arg)) : (0))
+#endif
+#endif
+
+// ---------------------------------------------------------------------
+/**
  * Simplified macro to send a verbose log message using the current LOG_TAG.
  */
 #ifndef LOGV
@@ -438,6 +454,7 @@ typedef enum {
 #define ALOGE(...) (ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__))
 #endif
 
+
 // ---------------------------------------------------------------------
 /**
  * Basic log message macro that allows you to specify a priority and a tag
diff --git a/log.c b/log.c
index ba68b5f..314a42b 100755 (executable)
--- a/log.c
+++ b/log.c
@@ -128,7 +128,7 @@ static int dlog_pri_to_journal_pri(log_priority prio)
 }
 static int __write_to_log_sd_journal_print(log_id_t log_id, log_priority prio, const char *tag, const char *msg)
 {
-       return sd_journal_print(dlog_pri_to_journal_pri(prio), "%c %s: %s",dlog_pri_to_char(prio), tag, msg);
+       return sd_journal_print(dlog_pri_to_journal_pri(prio), "%c %s: %s", dlog_pri_to_char(prio), tag, msg);
 }
 #endif
 void init_dlog_level(void)
index b9f2813..03a5276 100755 (executable)
--- a/logutil.c
+++ b/logutil.c
@@ -181,9 +181,12 @@ static void processBuffer(struct log_device_t* dev, struct logger_entry *buf)
 
        g_out_byte_count += bytes_written;
 
-    if (g_log_rotate_size_kbytes > 0 && (g_out_byte_count / 1024) >= g_log_rotate_size_kbytes)
-       {
-               rotate_logs();
+       if (g_log_rotate_size_kbytes > 0 && (g_out_byte_count / 1024) >= g_log_rotate_size_kbytes) {
+               if (g_nonblock) {
+                       exit(0);
+               } else {
+                       rotate_logs();
+               }
        }
 
 error:
index 0aac8ee..4930e4d 100755 (executable)
@@ -7,7 +7,10 @@ License:    Apache License, Version 2.0
 Source0:    %{name}-%{version}.tar.gz
 Source101:  dlog-main.service
 Source102:  dlog-radio.service
-Source103:  tizen-debug-level.service
+Source103:  packaging/dlogutil.manifest
+Source104:  packaging/libdlog.manifest
+Source105:  tizen-debug-level.service
+
 BuildRequires: pkgconfig(libsystemd-journal)
 Requires(post): /usr/bin/vconftool
 Requires(post): coreutils
@@ -55,9 +58,11 @@ make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
+cp %{SOURCE103} .
+cp %{SOURCE104} .
 %make_install
-mkdir -p %{buildroot}/opt/etc/
-cp %{_builddir}/%{name}-%{version}/.dloglevel %{buildroot}/opt/etc/.dloglevel
+mkdir -p %{buildroot}/opt/etc/dlog
+cp %{_builddir}/%{name}-%{version}/.dloglevel %{buildroot}/opt/etc/dlog/.dloglevel
 mkdir -p %{buildroot}/etc/profile.d/
 cp %{_builddir}/%{name}-%{version}/tizen_platform_env.sh %{buildroot}/etc/profile.d/tizen_platform_env.sh
 mkdir -p %{buildroot}/usr/bin/
@@ -72,7 +77,7 @@ mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
 
 install -m 0644 %SOURCE101 %{buildroot}%{_libdir}/systemd/system/
 install -m 0644 %SOURCE102 %{buildroot}%{_libdir}/systemd/system/
-install -m 0644 %SOURCE103 %{buildroot}%{_libdir}/systemd/system/
+install -m 0644 %SOURCE105 %{buildroot}%{_libdir}/systemd/system/
 
 ln -s ../dlog-main.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/dlog-main.service
 ln -s ../dlog-radio.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/dlog-radio.service
@@ -104,8 +109,12 @@ systemctl daemon-reload
 
 %files  -n dlogutil
 %manifest dlogutil.manifest
-%{_bindir}/dlogutil
-%attr(775,root,root) %{_bindir}/dlogctrl
+/usr/share/license/%{name}
+%doc LICENSE.APLv2
+%attr(755,root,root) /opt/etc/dlog/.dloglevel
+%attr(755,root,root) /etc/profile.d/tizen_platform_env.sh
+%attr(755,root,app_logging) %{_bindir}/dlogutil
+%attr(755,root,app_logging) %{_bindir}/dlogctrl
 %{_sysconfdir}/rc.d/init.d/dlog.sh
 %{_sysconfdir}/rc.d/rc3.d/S05dlog
 %{_libdir}/systemd/system/tizen-debug-level.service
@@ -114,13 +123,10 @@ systemctl daemon-reload
 %{_libdir}/systemd/system/basic.target.wants/tizen-debug-level.service
 %{_libdir}/systemd/system/multi-user.target.wants/dlog-main.service
 %{_libdir}/systemd/system/multi-user.target.wants/dlog-radio.service
-%attr(775,root,app) %dir /opt/etc/dlog
+%attr(775,root,app_logging) %dir /opt/etc/dlog
 
 %files  -n libdlog
-/usr/share/license/%{name}
-%doc LICENSE.APLv2
-/opt/etc/.dloglevel
-/etc/profile.d/tizen_platform_env.sh
+%manifest libdlog.manifest
 %{_libdir}/libdlog.so.0
 %{_libdir}/libdlog.so.0.0.0
 
similarity index 74%
rename from dlogutil.manifest
rename to packaging/dlogutil.manifest
index 4be9f3b..836adf4 100644 (file)
@@ -1,19 +1,10 @@
 <manifest>
        <define>
                <domain name="dlogutil"/>
-       <provide>
-               <label name="dlogutil::dlogutil"/>
-               <label name="dlogutil::dlogctrl"/>
-               <label name="dlogutil::dlog"/>
-       </provide>
        </define>
-       <request>
-               <domain name="dlogutil"/>
-       </request>
        <assign>
-               <filesystem path="/usr/bin/dlogutil" label="dlogutil::dlogutil"/>
-               <filesystem path="/usr/bin/dlogctrl" label="dlogutil::dlogctrl"/>
-               <filesystem path="/opt/etc/dlog" label="dlogutil::dlog"/>
+               <filesystem path="/usr/bin/dlogutil" label="_" exec_label="none"/>
+               <filesystem path="/usr/bin/dlogctrl" label="_" exec_label="none"/>
                <filesystem path="/etc/rc.d/init.d/dlog.sh" label="_" exec_label="none"/>
                <filesystem path="/etc/rc.d/rc3.d/S05dlog" label="_" exec_label="none"/>
                <filesystem path="/usr/lib/systemd/system/basic.target.wants/tizen-debug-level.service" label="_" exec_label="none" />
@@ -23,4 +14,7 @@
                <filesystem path="/usr/lib/systemd/system/multi-user.target.wants/dlog-radio.service" label="_" exec_label="none" />
                <filesystem path="/usr/lib/systemd/system/tizen-debug-level.service" label="_" exec_label="none" />
        </assign>
+       <request>
+               <domain name="dlogutil"/>
+       </request>
 </manifest>
diff --git a/packaging/libdlog.manifest b/packaging/libdlog.manifest
new file mode 100644 (file)
index 0000000..2292929
--- /dev/null
@@ -0,0 +1,9 @@
+<manifest>
+       <assign>
+               <filesystem path="/usr/lib/libdlog.so.0" label="_" exec_label="none"/>
+               <filesystem path="/usr/lib/libdlog.so.0.0" label="_" exec_label="none"/>
+       </assign>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
index ea9c420..563de1e 100644 (file)
@@ -7,7 +7,7 @@ ConditionFileExists=/opt/etc/dlog/.platformloggingmode
 
 [Service]
 Type=oneshot
-ExecStart=/bin/sh -c '/usr/bin/systemctl set-environment TIZEN_PLATFORMLOGGING_MODE=1 TIZEN_DLOG_LEVEL=$(cat /opt/etc/.dloglevel)'
+ExecStart=/bin/sh -c '/usr/bin/systemctl set-environment TIZEN_PLATFORMLOGGING_MODE=1 TIZEN_DLOG_LEVEL=$(cat /opt/etc/dlog/.dloglevel)'
 
 [Install]
 WantedBy=basic.target
index f8f0fe0..9bf35f1 100755 (executable)
@@ -7,7 +7,7 @@ fi
 # I'm not clear why "-a" doesn't work here
 if [ "x$TIZEN_PLATFORMLOGGING_MODE" != "x" ] &&
        [ "$TIZEN_PLATFORMLOGGING_MODE" -eq "1" ]; then
-       dlevel=$(cat /opt/etc/.dloglevel)
+       dlevel=$(cat /opt/etc/dlog/.dloglevel)
        if [ "$dlevel" -eq "0" ]; then
                export TIZEN_DLOG_LEVEL=0
        elif [ "$dlevel" -eq "1" ]; then