我找到了如何从portmap中取消注册NFS服务器rpcinfo -d,但我想强制nfs一旦开始运行就不要注册
我的意思是 - 如果我使用该命令service nfs restart- 服务器不应该rpcinfo -p在重启完成后显示
我正在使用CentOS 6.5,NFS版本3
我需要这个的原因是因为我在与NFS服务器相同的机器上运行代理服务器.代理签署portmap为nfs,我希望所有NFS调用都被重定向到NFS代理而不是NFS服务器 - 然后代理将消息转发到服务器
我将解释到目前为止我所做的所有步骤,并以我的问题结束.
使用OpenSSL 1.0.1e-fips 2013年2月11日
生成私钥和公钥
openssl genrsa -des3 -out private.pem 2048
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
Run Code Online (Sandbox Code Playgroud)
使用摘要和私钥签名消息
openssl dgst -sha256 -sign private.pem -out message.secret message.txt
Run Code Online (Sandbox Code Playgroud)
在这一点上,我有一个公钥,一个签名的消息(带摘要)和原始消息.
第1部分 - 使用CLI(这个工作)
使用CLI我设法验证摘要:
openssl dgst -sha256 -verify public.pem -signature message.secret message.txt
Run Code Online (Sandbox Code Playgroud)
我将"已验证"作为返回值.
第2部分 - 使用C程序
我的程序看起来像这样:
哪里:
msg是message.txt
签名是message.secret
pkey是公钥(使用PEM_read_PUBKEY实现)
int verify_it(const byte* msg, size_t msg_len, byte* signature, EVP_PKEY* pkey) {
EVP_MD_CTX *ctx;
size_t sig_len;
int bool_ret;
int ret_val;
ret_val = EXIT_SUCCESS;
ctx = NULL;
do
{
ctx = …Run Code Online (Sandbox Code Playgroud) 我有一个函数,用于分配给定大小的缓冲区.在返回之前,缓冲区将预处理/填充一些数据.此预处理可能返回false以表示此缓冲区未正确处理.所以我想在这个缓冲区上应用RAII,以避免在没有delete[]它的情况下提前返回.
通常我unique_ptr用来帮助我自动释放本地分配的对象.在这种情况下,我需要返回此分配的对象(拥有者unique_ptr)并将所有权转移给调用者.但是,编译器会抱怨,我不能转换unique_ptr<T[]>到T*,而我std::move的unique_ptr.它看起来unique_ptr只能移动到另一个unique_ptr而不是原始指针.
有没有办法将所有权转移unique_ptr到raw pointer?或者只是unique_ptr不适合这种情况?
bool PreProcess(int* v) { /* return nothing wrong? true: false; */ }
bool GetBuffer(int** ppRetBuf, int size)
{
std::unique_ptr<int[]> buf(new (std::nothrow) int[size]());
if(PreProcess(buf.get())
{
*ppRetBuf = std::move(buf); // Compiler complains:
// Error C2440 '=': cannot convert from 'std::unique_ptr<int [],std::default_delete<_Ty>>' to 'int *'
return true;
}
return false; // …Run Code Online (Sandbox Code Playgroud) #include <stdio.h>
#include <math.h>
long factcalc(int num1);
int main(void)
{
int num1;
long factorial;
int d;
int out;
printf("Please enter a number that is greater than 0");
scanf_s("%d", &num1);
if (num1 < 0) {
printf("Error, number has to be greater than 0");
} else if (num1 == 0) {
printf("\nThe answer is 1");
} else {
factorial = factcalc(num1);
printf("\nThe factorial of your number is\t %ld", factorial);
}
return 0;
}
long factcalc(int num1)
{
int factorial = 1;
int …Run Code Online (Sandbox Code Playgroud)