Fedora 13: when home directory is a subdir through nfs and/or link

By: | Comments: 13 Comments

Posted in categories: Computer Tips, Work related

When I upgraded my fedora boxes in a cluster to fedora 13, I found that I can nolonger login locally via graphical interface, and remote login dropped me to / since it could not change dir to user home.

I then

setenforce 0

All back to normal.

However,

audit2allow -m local -l -i /var/log/audit/audit.log

did not show any error, so do

grep seal /var/log/messages

And I did not find any reasonable solution from internet.

For order version of fedora, I used to use local.te to enable /home through nfs.  Now in version 13 it can be done by

setsebool -P use_nfs_home_dirs=1

But this did not change anything here.

So I went to check the path of real /home, and found that “home” has nfs_t attibute since it is a nfs mount.  This is supposed to be resolved by the above means.  However, “home” is not mounted under /, but under /data, which is attributed default_t.  I believe that this is the cause of the failure.

To solve this, I made a local.te file as

module local 1.0;

require {
type local_login_t;
type default_t;
type xauth_t;
type sshd_t;
class dir search;
}

#============= sshd_t ==============
allow sshd_t default_t:dir search;

#============= xauth_t ==============
allow xauth_t default_t:dir search;

#============= local_login_t ==============
allow local_login_t default_t:dir search;

This allows sshd, xauth and local_login to go through default_t.

By inserting this to the selinux policy, the issue is fixed.

Use rasdial to command line operate VPN

By: | Comments: 5 Comments

Posted in categories: Computer Tips, Work related

C:\>rasdial /?
USAGE:
rasdial entryname [username [password|*]] [/DOMAIN:domain]
[/PHONE:phonenumber] [/CALLBACK:callbacknumber]
[/PHONEBOOK:phonebookfile] [/PREFIXSUFFIX]

rasdial [entryname] /DISCONNECT

rasdial

Command completed successfully.

应该恢复立法打击投机倒把

By: | Comments: No Comments

Posted in categories: Opinions, 中文

应该恢复立法打击投机倒把.

旧定义:
投机倒把—-是指利用时机,以囤积居奇,买空卖空、掺杂作假、操纵物价等方式扰乱市场、牟取暴利的行为。投机倒把罪是指以获取非法利润为目的,违反金融、外汇、金银、物资、工商管理法规,非法从事工商业活动、扰乱国家金融和市场管理、破坏社会主义经济秩序,情节严重的行为。通俗点就是指某人在a地以低价买入在b地以高出买入价卖出就是投机倒把。

旧定义的问题:
1.定义混乱:做生意利用时机没有过错.掺杂作假是质量管理问题,不是投机倒把问题;
2.打击面过大:绝大多数正常商业行为就是在a地以低价买入在b地以高出买入价卖出.这是正常物流带来的合理增加值.

新定义:
投机倒把—-是指以操纵真实或虚拟资本流动或物资流动为手段故意制造人为或虚假短缺或过剩,以造成投资者,生产者,运输业者,销售业者,或消费者经济损失为代价获取利润的任何商业活动.

实例:拒绝消费者或面对消费者的零售商按市价购买要求;散布虚假短缺或过剩信息;以及通过控制仓储运输等渠道扭曲供求关系等商业行为.

Linux: add a swap file

By: | Comments: No Comments

Posted in categories: Computer Tips, Work related

To add a swap file:

  1. Determine the size of the new swap file and multiple by 1024 to determine the block size. For example, the block size of a 64 MB swap file is 65536.
  2. At a shell prompt as root, type the following command with count being equal to the desired block size:
    dd if=/dev/zero of=/swapfile bs=1024 count=65536
  3. Setup the swap file with the command:
    mkswap /swapfile
  4. To enable the swap file immediately but not automatically at boot time:
    swapon /swapfile
  5. To enable it at boot time, edit /etc/fstab to include:
    /swapfile               swap                    swap    defaults        0 0

    The next time the system boots, it will enable the new swap file.

  6. After adding the new swap file and enabling it, make sure it is enabled by viewing the output of the command cat /proc/swaps or free.

How to speak before the war?

By: | Comments: 4 Comments

Posted in categories: Uncategorized, 网文备份

打仗前怎么说话?

亲切友好的交谈——字面意思;
Cordial and friendly conversation — literally;

坦率交谈——分歧很大,无法沟通;
Frank conversation — has big differences, can not communicate;

交换了意见——会谈各说各的,没有达成协议;
Exchanged viewpoints — expressed themselves in the meeting, and there is no agreement;

充分交换了意见——双方无法达成协议,吵得厉害;
Fully exchanged point of views — the two sides could not reach an agreement, argued severely;

增进了双方的了解——双方分歧很大;
Enhanced mutual understanding — the two sides differ greatly;

会谈是有益的——双方目标暂时相距甚远,能坐下来谈就很好;
The talks are positive — the objectives of both sides are far away, it is good to be able to sit down and talk;

我们持保留态度——我们拒绝同意;
We reserve our opinions — we refuse to consent yours;

尊重——不完全同意;
Respect — do not fully agree;

赞赏——不尽同意;
Appreciate — do not entirely agree;

遗憾——不满;
Regret — dissatisfied;

不愉快——激烈的冲突;
Unpleasant — bitter conflict;

表示极大的愤慨——现在我拿你没办法;
Expressed great indignation — now I lack a way to take you down;

严重关切——可能要干预;
Serious concern — may have to interfere;

不能置之不理——即将干涉;
Can not ignore it — about to interfere;

保留做出进一步反应的权利——我们将报复;
Reserves the right of further reaction — we will retaliate;

我们将重新考虑这一问题的立场——我们已经改变了原来的(友好)政策;
We will reconsider our position on this issue — we have changed the original (friendly) policy;

拭目以待——最后警告;
Wait and see — the last warning;

请于*月*日前予以答复——*月*日后我们两国可能处于非和平状态;
Please answer before * month * month * — after the date the two countries may be in non-peaceful state;

由此引起的后果将由*负责——可能的话我国将诉诸武力(这也可能是虚张声势的俗语);
The resulting consequences will be your responsibility — if possible, we will resort to force (this may be bluff saying);

这是我们万万不能容忍的——战争在即;
This is what we absolutely can not tolerate — and the war is soon;

这是不友好的行动——这是敌视我们的行动;可能引起战争的行动;
This is a unfriendly action — action that is hostile to us; action may lead to war;

是可忍孰不可忍——不打算忍了,要动手了。
What cannot be tolerated if this is tolerable — do not intend to put up, ready to fight.

悬崖勒马——想被爆菊么?
Stop moving before you fall — want to be blasted?

勿谓言之不预也——准备棺材吧。
Do not say that we did not warn in advance — you are ready to be killed.

Grub boot without GUI

By: | Comments: No Comments

Posted in categories: Computer Tips, Work related

When booting, click any key to drop into grub booting menu, click Tab to bring up option line. Append 1 or 3 after the kernel line.  Then it will boot without GUI.

This is useful in case the X configuration is messed up.  Normal booting will result a locked display as well as locked mouse and keyboard.  By booting without GUI, you can get a chance to reinstall graphic drive, or fix X configuration.

selinux use nfs home dir

By: | Comments: 1 Comment

Posted in categories: Computer Tips, Work related

echo “1 1” > /selinux/use_nfs_home_dirs

Recursive prime triplet by Brillhart – Lehmer – Selfridge algorithm

By: | Comments: 7 Comments

Posted in categories: Fun Stuffs, Prime Search

Take any three primes, say p[1,0], p[2,0], and p[3,0].

Define:

p[i,j]=ABS[1+2*n[i,j]*p[(i+1) mod 3,j-1]*p[(i+2) mod 3,j-1]],n is the integer with minimum ABS[n] that makes p[i,j] a prime number.

The primality of p[i,j] can be proven using Brillhart – Lehmer – Selfridge algorithm recursively by using p[(i+1) mod 3,j-1] and p[(i+2) mod 3,j-1] as helper since n is a small integer, by reducing j to 0.

With this idea, taking

p[1,0]=3, p[2,0]=5, p[3,0]=7

We got the n[i,j] ( columns : j; rows: i):

i j=1 j=2 j=3
1 1 -1 -1
2 -1 2 -1
3 -8 -10 7
4 -14 -3 -13
5 -18 24 46
6 24 39 -32
7 225 -48 27
8 120 -76 30
9 -132 245 -676
10 316 -722 65
11 55 -1197 -510
12 -427 -1716 -637
13 4651 -1158 3420
14 -16337 17640 -18426
15 -8915 -70649 -31489
16 -18844 -92841 124053
17 -144011 -8853 -14042

The last three, p[i,17] makes top 5000 list.
The proof will be posted in the reply of this one.

The rank of primes

By: | Comments: 64 Comments

Posted in categories: Fun Stuffs, Prime Search

Brillhart – Lehmer – Selfridge algorithm provides a general primality proving method as long as you can factor P+1 or P-1. Therefore, for any prime number, when P+1 or P-1 get fully factored, the primality of any factors of P+1 or P-1 can also be proven by the same algorithm recursively.

For example, prime number P0=131, P0+1=132=2^2*3*11.
P1[1]=2 is trival prime, no recursion needed, recursion depth = 0;
P1[2]=3, P1[2]-1=2 is trival prime, one recursion, recursion depth = 1;
P1[3]=11; P1[3]+1=12=2^2*3; one more recursion from 3, recursion depth = 2;
So, P=131 has total maximum recursion depth 2+1 = 3.

We define the maximum recursion depth of the primality proving sequence using Brillhart – Lehmer – Selfridge algorithm as the rank of the prime number.

In this way, we can easily find, that
2 has the rank of 0;
3 is the smallest prime ranked 1;
11 is the smallest prime ranked 2;
131 is the smallest prime ranked 3;

The following Mathematica program is used to figure the rank of prime numbers until a rank 7 prime is found:

Fr[n_]:=
Module[{nm, np, fm, fp, szm, szp, maxm, maxp, thism, thisp, res, jm, jp},
If[n == 2, res = 0,
nm = n – 1; np = n + 1; fm = FactorInteger[nm]; fp = FactorInteger[np]; szm = Length[fm];
szp = Length[fp]; maxm = 0;
Do[thism = Fr[fm[[jm]][[1]]];
If[maxm < thism, maxm = thism], {jm, 1, szm}];
maxp = 0;
Do[thisp = Fr[fp[[jp]][[1]]];
If[maxp maxp, res = maxp]; res++]; res];
i=1;While[p = Prime[i]; s = Fr[p];[p, s] >>> “prime_rank.out”;s<7,i++]

The result:
1571 is the smallest prime ranked 4;
43717 is the smallest prime ranked 5;
5032843 is the smallest prime ranked 6;
1047774137 is the smallest prime ranked 7.

The result:
All Mersenne and Fermat primes have the rank of 1;
All Woodall, Cullen, General Woodall, General Cullen, General Fermat primes’ rank is one more than the rank of the highest ranked factor of k and n.

智利地震不可能造成国土面积增加1200平方公里

By: | Comments: 7 Comments

Posted in categories: Opinions, 中文

最大估计是12平方公里。不是1200。

理由:智利海岸线全长大约3000公里。以长出4米算,最多0。004×3000=12平方公里。

不知道是哪个脑残记者做的算术。

事实上,地震影响非常局域。能够导致位移四米的地段最多不超过2-3百公里。所以实际国土面积增加应该只有200×0.003=0.6平方公里就了不起了。