オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Annotation of /tags/htdocs/1.8/android-arm.html.en

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6362 - (hide annotations) (download)
Sun Nov 23 14:01:12 2014 UTC (9 years, 5 months ago) by kumaneko
File size: 20012 byte(s)


1 kumaneko 4325 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 kumaneko 3102 <html lang="en-US">
3     <head>
4 jnguyen 4560 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5     <meta http-equiv="content-style-type" content="text/css">
6     <link rel="stylesheet" href="../media/tomoyolinux.css" media="all" type="text/css">
7     <title>TOMOYO Linux 1.8.x : TOMOYO Linux on Android</title>
8 kumaneko 3102 </head>
9 jnguyen 4560
10 kumaneko 3102 <body>
11    
12 jnguyen 4560 <div id="titlebar">
13 kumaneko 5210 <a href="../index.html.en"><img src="../media/tomoyotitle.png" alt="tomoyotitle.png" width="320" height="40" border="0" align="left" title="TOMOYO Linux"></a>
14 jnguyen 4560 </div>
15 kumaneko 3801
16 jnguyen 4560 <div id="navbar" class="tomoyo-documentation">
17     <ul id="navbarlist">
18     <li id="tomoyo-home"><a href="../index.html.en" title="TOMOYO Linux Home Page">Home</a></li>
19     <li id="tomoyo-about"><a href="../about.html.en" title="About TOMOYO Linux">About</a></li>
20     <li id="tomoyo-download"><a href="../download.html.en" title="Get TOMOYO Linux">Download</a></li>
21     <li id="tomoyo-changelogs"><a href="../changelogs.html.en" title="TOMOYO Linux ChangeLogs">ChangeLogs</a></li>
22     <li id="tomoyo-documentation"><a href="../documentation.html.en" title="Official Documentation">Documentation</a></li>
23     <li id="tomoyo-support"><a href="../support.html.en" title="Support information">Support</a></li>
24     <li id="tomoyo-links"><a href="../links.html.en" title="Links">Links</a></li>
25     </ul>
26     <ul id="switch-language">
27     <li id="tomoyo-switch-language"><a href="android-arm.html.ja" title="Go to Japanese page">Japanese page</a></li>
28     </ul>
29     </div>
30    
31     <div id="content">
32    
33     <div id="regular-content">
34    
35     <h2>TOMOYO Linux on Android</h2>
36    
37 kumaneko 5785 <p>This page describes how to run TOMOYO Linux on Android emulator for ARM architecture. This page assumes Ubuntu 10.04.3 for x86_64 architecture as the host environment.</p>
38 kumaneko 3102
39 jnguyen 4560 <h3>Step 1: Install required packages.</h3>
40 kumaneko 3102
41 kumaneko 3765 <p>Install packages as suggested at <a href="http://source.android.com/source/download.html">http://source.android.com/source/download.html</a> .</p>
42 kumaneko 3102
43 jnguyen 4560 <pre class="command">
44 kumaneko 4713 sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
45     sudo add-apt-repository "deb-src http://archive.canonical.com/ubuntu lucid partner"
46     sudo apt-get update
47 kumaneko 5799 sudo apt-get install sun-java6-jdk
48 kumaneko 5786 sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev \
49     lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
50     libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc
51 jnguyen 4560 </pre>
52 kumaneko 3102
53 jnguyen 4560 <h3>Step 2: Set environment variables.</h3>
54 kumaneko 3102
55 kumaneko 4713 <p>Set environment variables shown below. Adding to user's initrc script (e.g. ~/.bashrc ) is recommended.</p>
56 kumaneko 3102
57 jnguyen 4560 <pre class="command">
58     export ANDROID_HOME=$HOME/mydroid/
59     export ANDROID_IMG=$ANDROID_HOME/image/
60     </pre>
61 kumaneko 3102
62 kumaneko 4713 <p>Create directories.</p>
63    
64     <pre class="command">
65     mkdir -p $ANDROID_HOME
66     mkdir -p $ANDROID_HOME/tmp
67     mkdir -p $ANDROID_HOME/tmp/policy
68     mkdir -p $ANDROID_IMG
69     mkdir -p $ANDROID_IMG/tmp
70 kumaneko 5794 sudo mkdir -p /var/log/tomoyo
71 kumaneko 4713 sudo chown -R `id -u` /var/log/tomoyo/
72     </pre>
73    
74 jnguyen 4560 <h3>Step 3: Build the Android environment.</h3>
75 kumaneko 3102
76     <p>Download the source code and compile the emulator.</p>
77    
78 jnguyen 4560 <pre class="command">
79     cd $ANDROID_HOME
80 kumaneko 5785 wget https://dl-ssl.google.com/dl/googlesource/git-repo/repo
81 jnguyen 4560 chmod 755 repo
82 kumaneko 5794 ./repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
83 jnguyen 4560 ./repo sync
84 kumaneko 5794 source build/envsetup.sh
85     lunch full-eng
86 kumaneko 3102 make
87 jnguyen 4560 </pre>
88 kumaneko 3102
89 kumaneko 4713 <h3>Step 4: Compile tools for host environment.</h3>
90 kumaneko 3102
91 kumaneko 4713 <p>Install TOMOYO Linux's userland tools into host environment in order to manage Android emulator remotely.</p>
92 kumaneko 3102
93 jnguyen 4560 <pre class="command">
94     cd $ANDROID_HOME/tmp/
95 kumaneko 6332 wget -O ccs-tools-1.8.3-20140601.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/tomoyo/49693/ccs-tools-1.8.3-20140601.tar.gz'
96     wget -O ccs-tools-1.8.3-20140601.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/tomoyo/49693/ccs-tools-1.8.3-20140601.tar.gz.asc'
97 kumaneko 5794 wget http://I-love.SAKURA.ne.jp/kumaneko-key
98     gpg --import kumaneko-key
99 kumaneko 6332 gpg ccs-tools-1.8.3-20140601.tar.gz.asc
100     tar -zxf ccs-tools-1.8.3-20140601.tar.gz
101 kumaneko 5999 cd ccs-tools
102 kumaneko 4713 make
103     sudo make install
104 jnguyen 4560 </pre>
105 kumaneko 3102
106 kumaneko 4713 <p>Also, create default configuration in order to prepare for policy management tools.</p>
107 kumaneko 3102
108 jnguyen 4560 <pre class="command">
109 kumaneko 4713 sudo /usr/lib/ccs/init_policy
110     sudo chown -R `id -u` /etc/ccs/
111     echo 'rewrite head_pattern /acct/uid/\$/' &gt;&gt; /etc/ccs/tools/patternize.conf
112 jnguyen 4560 </pre>
113 kumaneko 3102
114 kumaneko 4713 <h3>Step 5: Compile tools for emulator environment.</h3>
115 kumaneko 3102
116 kumaneko 4713 <p>Install TOMOYO Linux's agent program into Android emulator environment.</p>
117 kumaneko 3102
118 jnguyen 4560 <pre class="command">
119     cd $ANDROID_HOME/tmp/
120     wget -O agcc http://plausible.org/andy/agcc
121 kumaneko 5788 sed -i -e 's@4\.2\.1@4.4.3@g' -e 's@interwork/@@g' -- agcc
122 jnguyen 4560 chmod 755 agcc
123 kumaneko 5998 ./agcc -o ccs-editpolicy-agent $ANDROID_HOME/tmp/ccs-tools/usr_lib_ccs/ccs-editpolicy-agent.c
124 kumaneko 4713 chmod 700 ccs-editpolicy-agent
125 jnguyen 4560 </pre>
126 kumaneko 3102
127 kumaneko 4713 <h3>Step 6: Create initial policy.</h3>
128 kumaneko 3102
129 kumaneko 4713 <p>Create initial policy which will be embedded into the kernel.</p>
130 kumaneko 3102
131 kumaneko 4713 <ul>
132     <li>Use profile 1 (which is a profile for "learning mode") to all domains.</li>
133     <li>Automatically transit to "&lt;kernel&gt; //./system-user" domain when the current process's UID or GID has changed from 0 to 1 to 9999.</li>
134     <li>Automatically transit to "&lt;kernel&gt; //./app-user" domain when the current process's UID or GID has changed from 0 to 10000 or above.</li>
135     <li>Give some permission from the beginning.</li>
136     <li>Do not distinguish individual Android applications.</li>
137     <li>Only /sbin/ccs-editpolicy-agent is allowed to modify policy via /proc/ccs/ interface.</li>
138     </ul>
139    
140     <p>An example with conditions above is shown below. But it would be too loose to give write access to ANY_PATHNAME to "&lt;kernel&gt; //./app-user" domain. When applying to real devices, you should use more strict permissions such as forbidding write access to /system/ directory.</p>
141    
142 jnguyen 4560 <pre class="command">
143 kumaneko 4713 cd $ANDROID_HOME/tmp/policy/
144     cat &gt; profile.conf &lt;&lt; "EOF"
145     PROFILE_VERSION=20100903
146     0-COMMENT=-----Disabled Mode-----
147     0-PREFERENCE={ max_audit_log=1024 max_learning_entry=2048 enforcing_penalty=0 }
148     0-CONFIG={ mode=disabled grant_log=no reject_log=yes }
149     1-COMMENT=-----Learning Mode-----
150     1-PREFERENCE={ max_audit_log=1024 max_learning_entry=2048 enforcing_penalty=0 }
151     1-CONFIG={ mode=learning grant_log=no reject_log=yes }
152     2-COMMENT=-----Permissive Mode-----
153     2-PREFERENCE={ max_audit_log=1024 max_learning_entry=2048 enforcing_penalty=0 }
154     2-CONFIG={ mode=permissive grant_log=no reject_log=yes }
155     3-COMMENT=-----Enforcing Mode-----
156     3-PREFERENCE={ max_audit_log=1024 max_learning_entry=2048 enforcing_penalty=0 }
157     3-CONFIG={ mode=enforcing grant_log=no reject_log=yes }
158     EOF
159     cat &gt; exception_policy.conf &lt;&lt; "EOF"
160     path_group ANY_PATHNAME /
161     path_group ANY_PATHNAME /\{\*\}/
162     path_group ANY_PATHNAME /\{\*\}/\*
163     path_group ANY_PATHNAME /\*
164     path_group ANY_PATHNAME \*:/
165     path_group ANY_PATHNAME \*:/\{\*\}/
166     path_group ANY_PATHNAME \*:/\{\*\}/\*
167     path_group ANY_PATHNAME \*:/\*
168     path_group ANY_PATHNAME \*:[\$]
169     path_group ANY_PATHNAME socket:[family=\$:type=\$:protocol=\$]
170     acl_group 0 file getattr @ANY_PATHNAME
171     acl_group 0 file ioctl @ANY_PATHNAME 0-0xFFFFFFFF
172     acl_group 0 file read /dev/urandom
173     acl_group 0 file read /system/bin/linker
174     acl_group 0 file read /system/lib/lib\*.so
175     acl_group 0 misc env _
176     acl_group 0 misc env ANDROID_ASSETS
177     acl_group 0 misc env ANDROID_BOOTLOGO
178     acl_group 0 misc env ANDROID_DATA
179     acl_group 0 misc env ANDROID_DNS_MODE
180     acl_group 0 misc env ANDROID_PROPERTY_WORKSPACE
181     acl_group 0 misc env ANDROID_ROOT
182     acl_group 0 misc env ANDROID_SOCKET_\*
183     acl_group 0 misc env ASEC_MOUNTPOINT
184     acl_group 0 misc env BOOTCLASSPATH
185     acl_group 0 misc env EXTERNAL_STORAGE
186     acl_group 0 misc env HOME
187     acl_group 0 misc env LD_LIBRARY_PATH
188     acl_group 0 misc env LOOP_MOUNTPOINT
189     acl_group 0 misc env ndns
190     acl_group 0 misc env PATH
191     acl_group 0 misc env qemu
192     acl_group 0 misc env RANDOM
193     acl_group 0 misc env SHELL
194     acl_group 0 misc env TERM
195     acl_group 0 task auto_domain_transition &lt;kernel&gt; //./app-user task.gid=10000-4294967295
196     acl_group 0 task auto_domain_transition &lt;kernel&gt; //./app-user task.uid=10000-4294967295
197     acl_group 0 task auto_domain_transition &lt;kernel&gt; //./system-user task.gid=1-9999
198     acl_group 0 task auto_domain_transition &lt;kernel&gt; //./system-user task.uid=1-9999
199     acl_group 1 file getattr @ANY_PATHNAME
200     acl_group 1 file ioctl @ANY_PATHNAME 0-0xFFFFFFFF
201     acl_group 1 file read /dev/urandom
202     acl_group 1 file read /system/bin/linker
203     acl_group 1 file read /system/lib/lib\*.so
204     acl_group 1 misc env _
205     acl_group 1 misc env ANDROID_ASSETS
206     acl_group 1 misc env ANDROID_BOOTLOGO
207     acl_group 1 misc env ANDROID_DATA
208     acl_group 1 misc env ANDROID_PROPERTY_WORKSPACE
209     acl_group 1 misc env ANDROID_ROOT
210     acl_group 1 misc env ANDROID_SOCKET_\*
211     acl_group 1 misc env ASEC_MOUNTPOINT
212     acl_group 1 misc env BOOTCLASSPATH
213     acl_group 1 misc env EXTERNAL_STORAGE
214     acl_group 1 misc env HOME
215     acl_group 1 misc env HOSTNAME
216     acl_group 1 misc env LD_LIBRARY_PATH
217     acl_group 1 misc env LOOP_MOUNTPOINT
218     acl_group 1 misc env MKSH
219     acl_group 1 misc env PATH
220     acl_group 1 misc env PS1
221     acl_group 1 misc env RANDOM
222     acl_group 1 misc env SHELL
223     acl_group 1 misc env TERM
224     acl_group 1 misc env USER
225     EOF
226     cat &gt; domain_policy.conf &lt;&lt; "EOF"
227     &lt;kernel&gt;
228     use_profile 1
229     use_group 0
230    
231     &lt;kernel&gt; //./system-user
232     use_profile 1
233     use_group 1
234    
235     file read/write/unlink/rmdir/truncate/symlink @ANY_PATHNAME task.euid=1-9999 task.egid=1-9999
236     file create/mkdir/mkfifo/mksock/chmod @ANY_PATHNAME 0-0777 task.euid=1-9999 task.egid=1-9999
237     file link/rename @ANY_PATHNAME @ANY_PATHNAME task.euid=1-9999 task.egid=1-9999
238    
239     &lt;kernel&gt; //./app-user
240     use_profile 1
241     use_group 1
242    
243     file read/write/unlink/rmdir/truncate/symlink @ANY_PATHNAME task.euid=10000-4294967295 task.egid=10000-4294967295
244     file create/mkdir/mkfifo/mksock/chmod @ANY_PATHNAME 0-0777 task.euid=10000-4294967295 task.egid=10000-4294967295
245     file link/rename @ANY_PATHNAME @ANY_PATHNAME task.euid=10000-4294967295 task.egid=10000-4294967295
246     EOF
247     echo /sbin/ccs-editpolicy-agent &gt; manager.conf
248     echo &gt; stat.conf
249 jnguyen 4560 </pre>
250 kumaneko 3102
251 kumaneko 4713 <h3>Step 7: Build the Android kernel.</h3>
252 kumaneko 3102
253 kumaneko 4713 <p>Download and extract the kernel source code.</p>
254 kumaneko 3102
255 jnguyen 4560 <pre class="command">
256 kumaneko 4713 cd $ANDROID_HOME/tmp/
257 kumaneko 5787 git clone https://android.googlesource.com/kernel/goldfish
258     cd goldfish/
259     git checkout origin/android-goldfish-2.6.29
260 kumaneko 5800 ARCH=arm CROSS_COMPILE=$ANDROID_EABI_TOOLCHAIN/arm-linux-androideabi- make -s goldfish_armv7_defconfig
261 jnguyen 4560 </pre>
262 kumaneko 3102
263 kumaneko 4713 <p>Apply TOMOYO Linux patch.</p>
264 kumaneko 3102
265 kumaneko 4713 <pre class="command">
266 kumaneko 5787 cd $ANDROID_HOME/tmp/goldfish/
267 kumaneko 6362 wget -O ccs-patch-1.8.3-20141123.tar.gz 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/tomoyo/49684/ccs-patch-1.8.3-20141123.tar.gz'
268     wget -O ccs-patch-1.8.3-20141123.tar.gz.asc 'http://sourceforge.jp/frs/redir.php?m=jaist&amp;f=/tomoyo/49684/ccs-patch-1.8.3-20141123.tar.gz.asc'
269     gpg ccs-patch-1.8.3-20141123.tar.gz.asc
270     tar -zxf ccs-patch-1.8.3-20141123.tar.gz
271 kumaneko 4713 patch -p1 &lt; patches/ccs-patch-2.6.29-android-goldfish.diff
272 kumaneko 5143 sed -e 's/# CONFIG_CCSECURITY_OMIT_USERSPACE_LOADER is not set/CONFIG_CCSECURITY_OMIT_USERSPACE_LOADER=y/' -- config.ccs &gt;&gt; .config
273 kumaneko 5788 mkdir -p security/ccsecurity/policy/
274 kumaneko 5144 cp -p $ANDROID_HOME/tmp/policy/*.conf security/ccsecurity/policy/
275 kumaneko 5143 </pre>
276    
277 kumaneko 4713 <p>Compile the kernel.</p>
278    
279 jnguyen 4560 <pre class="command">
280 kumaneko 5787 cd $ANDROID_HOME/tmp/goldfish/
281 kumaneko 5796 ARCH=arm CROSS_COMPILE=$ANDROID_EABI_TOOLCHAIN/arm-linux-androideabi- make -s
282 kumaneko 4713 cp -p arch/arm/boot/zImage $ANDROID_IMG/kernel.img
283 jnguyen 4560 </pre>
284 kumaneko 3102
285 kumaneko 4713 <h3>Step 8: Copy Android's image files.</h3>
286 kumaneko 3102
287 kumaneko 4713 <p>Copy image file used by Android emulator.</p>
288 kumaneko 3102
289 jnguyen 4560 <pre class="command">
290 kumaneko 4713 cd $ANDROID_HOME/out/target/product/generic/
291     cp -p system.img ramdisk.img userdata.img $ANDROID_IMG
292 jnguyen 4560 </pre>
293 kumaneko 3102
294 kumaneko 4713 <h3>Step 9: Edit Android's ramdisk image.</h3>
295 kumaneko 3102
296 kumaneko 4713 <p>Copy the agent program into Android emulator's ramdisk and configure the agent to be automatically executed upon boot.</p>
297 kumaneko 3102
298 jnguyen 4560 <pre class="command">
299     cd $ANDROID_IMG/tmp/
300 kumaneko 4713 zcat ../ramdisk.img | cpio -id
301     echo &gt;&gt; init.rc
302     echo 'service ccs_agent /sbin/ccs-editpolicy-agent 0.0.0.0:7000' &gt;&gt; init.rc
303 kumaneko 5785 echo '&nbsp;&nbsp;&nbsp;&nbsp;class core' &gt;&gt; init.rc
304 kumaneko 4713 echo '&nbsp;&nbsp;&nbsp;&nbsp;oneshot' &gt;&gt; init.rc
305     cp -p $ANDROID_HOME/tmp/ccs-editpolicy-agent sbin/
306     find . -print0 | cpio -o0 -H newc | gzip -9 &gt; ../ramdisk.img
307     </pre>
308 jnguyen 4560
309 kumaneko 4713 <h3>Step 10: Start the Android emulator.</h3>
310 jnguyen 4560
311 kumaneko 4713 <p>Start the Android emulator. Specify the kernel made at step 7 and the ramdisk made at step 9.</p>
312 jnguyen 4560
313 kumaneko 4713 <pre class="command">
314     emulator -kernel $ANDROID_IMG/kernel.img -ramdisk $ANDROID_IMG/ramdisk.img -sysdir $ANDROID_IMG \
315     -data $ANDROID_IMG/userdata.img -show-kernel
316     </pre>
317 jnguyen 4560
318 kumaneko 4713 <h3>Step 11: Enable TCP port forwarding.</h3>
319 jnguyen 4560
320 kumaneko 4713 <p>Configure port forwarding in order to communicate with the agent program running in the emulator. Below line makes TCP connection requests sent to host environment's port 10000 are forwarded to emulator environment's port 7000. As you have configures ccs-editpolicy-agent to listen at port 7000 at step 9, you can communicate with the agent program by connecting to host environment's port 10000.</p>
321    
322     <pre class="command">
323     adb forward tcp:10000 tcp:7000
324 jnguyen 4560 </pre>
325 kumaneko 3102
326 kumaneko 4713 <h3>Step 12: Operate via agent.</h3>
327 kumaneko 3102
328 kumaneko 4713 <p>You can browse/edit policy via agent program by starting ccs-editpolicy as shown below.</p>
329 kumaneko 3102
330 jnguyen 4560 <pre class="command">
331 kumaneko 4713 /usr/sbin/ccs-editpolicy 127.0.0.1:10000
332 jnguyen 4560 </pre>
333 kumaneko 3102
334 kumaneko 4713 <p>You can save audit logs by starting ccs-auditd as shown below. Please be careful with disk's free space because a lot of logs are generated.</p>
335 kumaneko 3102
336 kumaneko 4713 <pre class="command">
337     /usr/sbin/ccs-auditd 127.0.0.1:10000
338     </pre>
339 kumaneko 3102
340 kumaneko 4713 <p>You can interactively handle policy violation in enforcing mode by starting ccs-queryd as shown below. Press Ctrl-C to terminate ccs-queryd.</p>
341    
342 jnguyen 4560 <pre class="command">
343 kumaneko 4713 /usr/sbin/ccs-queryd 127.0.0.1:10000
344 jnguyen 4560 </pre>
345 kumaneko 3102
346 kumaneko 4713 <p>You can make patterns by running ccs-patternize as show below. Edit /etc/ccs/tools/patternize.conf as needed since the rules for making patterns are defined in that file.</p>
347 kumaneko 3102
348 jnguyen 4560 <pre class="command">
349 kumaneko 4713 cd $ANDROID_HOME/tmp/policy/
350     /usr/sbin/ccs-savepolicy -d 127.0.0.1:10000 &gt; domain_policy.old
351     /usr/sbin/ccs-patternize &lt; domain_policy.old &gt; domain_policy.new
352     /usr/sbin/ccs-diffpolicy domain_policy.old domain_policy.new &gt; domain_policy.diff
353     less domain_policy.diff
354     /usr/sbin/ccs-loadpolicy -d 127.0.0.1:10000 &lt; domain_policy.diff
355 jnguyen 4560 </pre>
356 kumaneko 3102
357 kumaneko 4713 <h3>Step 13: Updating policy</h3>
358 kumaneko 3102
359 kumaneko 4713 <p>Since the policy updated after the boot resides only in the kernel memory, the updated policy will be lost when the emulator is terminated. Be sure to save the updated policy before terminating the emulator.</p>
360 kumaneko 3102
361 jnguyen 4560 <pre class="command">
362 kumaneko 4713 cd $ANDROID_HOME/tmp/policy/
363     /usr/sbin/ccs-savepolicy -e 127.0.0.1:10000 &gt; exception_policy.conf
364     /usr/sbin/ccs-savepolicy -d 127.0.0.1:10000 &gt; domain_policy.conf
365     /usr/sbin/ccs-savepolicy -p 127.0.0.1:10000 &gt; profile.conf
366 jnguyen 4560 </pre>
367 kumaneko 3102
368 kumaneko 4713 <p>Run below commands to update policy which will be embedded into the kernel.</p>
369 kumaneko 3102
370 jnguyen 4560 <pre class="command">
371 kumaneko 5787 cp -p $ANDROID_HOME/tmp/policy/*.conf $ANDROID_HOME/tmp/goldfish/security/ccsecurity/policy/
372 jnguyen 4560 </pre>
373 kumaneko 3102
374 kumaneko 4713 <p>Recompile the Android kernel.</p>
375 kumaneko 3102
376 jnguyen 4560 <pre class="command">
377 kumaneko 5787 cd $ANDROID_HOME/tmp/goldfish/
378 kumaneko 5796 ARCH=arm CROSS_COMPILE=$ANDROID_EABI_TOOLCHAIN/arm-linux-androideabi- make -s
379 kumaneko 4713 cp -p arch/arm/boot/zImage $ANDROID_IMG/kernel.img
380 jnguyen 4560 </pre>
381 kumaneko 3102
382 kumaneko 4713 <p>Restart the Android emulator.</p>
383 kumaneko 3102
384 jnguyen 4560 <pre class="command">
385 kumaneko 4713 emulator -kernel $ANDROID_IMG/kernel.img -ramdisk $ANDROID_IMG/ramdisk.img -sysdir $ANDROID_IMG \
386     -data $ANDROID_IMG/userdata.img -show-kernel
387 jnguyen 4560 </pre>
388 kumaneko 3102
389 kumaneko 4713 <p>When you have finished developing the final policy files, you can specify a profile for enforcing mode (use_profile 3) to domain_policy.conf which will be embedded into the kernel. By using a profile for enforcing mode, you can enable access control from the moment /init in the initramfs is executed. After you have verified that the emulator works as expected with a profile for enforcing mode, you can remove /sbin/ccs-editpolicy-agent added at step 9. Also, you can remove ccs-editpolicy-agent from /init.rc and from profile.conf which will be embedded into the kernel.</p>
390    
391     <h3>Appendix: Hints for allowing policy updates after boot</h3>
392    
393     <p>Regarding Android devices, users can add applications which are not shipped with the device. Above procedure assumed there will be no need for updating policy when applications are added by categorizing into 3 groups based on the Linux's UID value.</p>
394    
395     <p>However, you may want to allow updating policy when special applications are added. In that case, you can split policy files into the "fixed" part which will be embedded into the kernel for use at the boot stage and the "variant" part which will not be embedded into the kernel for use after the boot stage.</p>
396    
397     <p>You can reduce the risk of tampering the "fixed" part by deploying the kernel into the read-only partition. But you may not be able to reduce the risk of tampering the "variant" part because the "variant" part will likely be located into the read-write partition. In that case, you can use (e.g.) GPG signature and append the policy into the kernel only when you verified that the "variant" part is not tampered.</p>
398    
399     <p>TOMOYO Linux provides a mechanism for querying external userland application when a policy violation in enforcing mode has occurred. You can implement a program like ccs-queryd and daemonize the program instead of ccs-editpolicy-agent .</p>
400    
401 kumaneko 5416 <h3>Appendix: Hints for not embedding policy into the kernel</h3>
402    
403     <p>If you want not to embed policy files into your kernel by some reason, you can replace</p>
404    
405     <pre class="command">
406     sed -e 's/# CONFIG_CCSECURITY_OMIT_USERSPACE_LOADER is not set/CONFIG_CCSECURITY_OMIT_USERSPACE_LOADER=y/' -- config.ccs &gt;&gt; .config
407 kumaneko 5789 mkdir -p security/ccsecurity/policy/
408 kumaneko 5416 cp -p $ANDROID_HOME/tmp/policy/*.conf security/ccsecurity/policy/
409     </pre>
410    
411     <p>with</p>
412    
413     <pre class="command">
414 kumaneko 5801 sed -e 's:/sbin/init:/init:' -- config.ccs &gt;&gt; .config
415 kumaneko 5416 </pre>
416    
417 kumaneko 5802 <p>in Step 7. If you do so, you will need to copy /sbin/ccs-init (as a policy loader, and /system/bin/linker /system/lib/libc.so /system/lib/libm.so which /sbin/ccs-init depends on) into ramdisk image. You cannot use symlinks to files in /system/ partition because /system/ partition is not yet mounted as of /sbin/ccs-init is executed. Also, please modify ccs-init.c as needed (for example, embed the content of $ANDROID_HOME/tmp/policy/*.conf into ccs-init.c) because it is designed to read policy files from /etc/ccs/ directory. Below example changes ccs-init.c to read policy files from /ccs/ directory because /init.rc in Android emulator's ramdisk creates /etc as a symlink to /system/etc/ directory.</p>
418 kumaneko 5416
419     <pre class="command">
420     cd $ANDROID_HOME/tmp/
421 kumaneko 5998 sed -e 's:etc/ccs:ccs:g' $ANDROID_HOME/tmp/ccs-tools/sbin/ccs-init.c &gt; $ANDROID_HOME/tmp/ccs-tools/sbin/ccs-init2.c
422     ./agcc -o ccs-init $ANDROID_HOME/tmp/ccs-tools/sbin/ccs-init2.c
423 kumaneko 5802 cd $ANDROID_IMG/tmp/
424     mkdir -p sbin system/bin system/lib
425     cp -p $ANDROID_HOME/tmp/ccs-init sbin/
426     cp -p $ANDROID_HOME/out/target/product/generic/system/bin/linker system/bin/
427     cp -p $ANDROID_HOME/out/target/product/generic/system/lib/libc.so system/lib/
428     cp -p $ANDROID_HOME/out/target/product/generic/system/lib/libm.so system/lib/
429     chmod 700 sbin/ccs-init system/bin/linker system/lib/libc.so system/lib/libm.so
430     find . -print0 | cpio -o0 -H newc | gzip -9 &gt; ../ramdisk.img
431 kumaneko 5416 </pre>
432    
433 jnguyen 4560 </div><!-- regular-content -->
434 kumaneko 3102
435 jnguyen 4560 </div><!-- content -->
436    
437 jnguyen 4566 <div id="navfooter">
438     <hr>
439     <table>
440     <tr>
441     <td class="docs-previous">
442     </td>
443     <td class="docs-index">
444     <a href="index.html.en">Index</a>
445     </td>
446     <td class="docs-next">
447     </td>
448     </tr>
449     <tr>
450     <td class="docs-previous-description">
451     </td>
452     <td class="docs-home">
453     </td>
454     <td class="docs-next-description">
455     </td>
456     </tr>
457     </table>
458     </div>
459    
460 jnguyen 4560 <div id="footer">
461     <p class="language">Go to <a href="android-arm.html.ja">Japanese page</a>.</p>
462     <p class="timestamp">Last modified: $Date$</p>
463 kumaneko 6347 <p class="trademark">Linux&reg; is a registered trademark of Linus Torvalds world-wide. TOMOYO&reg; is a registered trademark of <a href="http://www.nttdata.com/global/en/">NTT DATA Corporation</a>.</p>
464 kumaneko 5210 <p><a href="http://sourceforge.jp/"><img src="http://sourceforge.jp/sflogo.php?group_id=1973" width="96" height="31" alt="sflogo.php" title="SourceForge.jp"></a></p>
465 jnguyen 4560 </div>
466    
467 kumaneko 3102 </body>
468     </html>

Properties

Name Value
svn:keywords Date

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26